exceljs / exceljs

Excel Workbook Manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

row height doesn't apply to row

dong-qian opened this issue · comments

Default row height does not apply to the excel generated.

 let infoSheet = this.workbook.addWorksheet("Info", {properties:{ defaultRowHeight: 50 }});

or

infoSheet.properties.defaultRowHeight = 50;

rowheight

I use this and it works.
sheet.properties.defaultRowHeight = 40;

I this
sheet.properties.defaultRowHeight = 40;
not work

I had the same issue, but i find the following code works:
sheet.getRow(2).height = 100;
sheet.getRow(3).height = 200;
...

commented

the same problem, just want to add a min height style.

Having same issue

For other people having this issue: Are you first opening the generated excel files on the Windows version of Excel 2016?
I've seen something on that platform where Excel will do weird resizing of rows on a worksheet. I painstakingly tracked this down to exceljs not generating a element, causing Excel to flip. I fixed this by adding an empty view to all of my worksheets via worksheet.views = [{}]

@ScottPeterJohnson thanks very much.

worksheet.views = [{}] works for me

I experienced the same "weird resizing of rows". (FWIW I had first opened the exceljs-generated .xlsx file on the macOS version of MS Excel) And I found that MS Excel-generated .xlsx file has the following XML element in xl/worksheets/sheet1.xml and @ScottPeterJohnson's worksheet.views = [{}] also adds the element:

...

<!-- <dimension ... /> -->
<sheetViews>
  <sheetView workbookViewId="0" />
</sheetViews>
<!-- <sheetFormatPr ... /> -->

...

This addition seems to solve the issue but I couldn't find any explanation of that from MS Documentation:

workbookViewId (Workbook View Index): Zero-based index of this workbook view, pointing to a workbookView element in the bookViews collection. The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.

So for now I can't propose to make it a default option for worksheet.views which can be done by editing below code:

this.views = options.views || [];