protobi / js-xlsx

XLSX / XLSM / XLSB (Excel 2007+ Spreadsheet) / ODS parser and writer
http://oss.sheetjs.com/js-xlsx
Other
833 stars 416 forks source link

xlsx-style cell merged areas border #96

Closed ackuikui closed 6 years ago

ackuikui commented 6 years ago

How can I set merged areas border?

there is in doc

Borders for merged areas are specified for each cell within the merged area. So to apply a box border to a merged area of 3x3 cells, border styles would need to be specified for eight different cells: left borders for the three cells on the left, right borders for the cells on the right top borders for the cells on the top bottom borders for the cells on the left

I can set border with

  border: {
    top: { style: 'thin', color: {theme: 5, tint: 0.6} },
    bottom: { style: 'thin', color: {theme: 5, tint: 0.6} },
    left: { style: 'thin', color: {theme: 5, tint: 0.6} },
    right: { style: 'thin', color: {theme: 5, tint: 0.6} }
  }
wolfgang42 commented 6 years ago

It would seem that in order to get a border on an entire merged cell you must set the border style on all of the cells that were merged. So, if you have merged cells B1-B5 you must set the style on B1, B2, B3, B4, and B5. The value of B2-B5 will be ignored but the border will still be applied.

ackuikui commented 6 years ago

@wolfgang42 That's great! cells within the merged area need to set. there I have to fillworksheet['B2'] = { t: 'z', s: { border: {...} } }; while worksheet['B2'] is undefined when I use XLSX.utils.table_to_sheet() or worksheet['!merges']= [{s: {r: 1, c: 1}, e: {r: 1, c: 3}}]