Hi, I am currently upgrading my client's 2009 classic to 2018, and there's some excel export report.
The report needs to set fixed column width ,row height and zoom, in 2009 using automation is simple like:
SetHeight(pHeight : Decimal)
IF pHeight > 0 THEN
XlWrkSht.Range('A' + FORMAT(1) + ':' + xlColID + xlRowID).RowHeight := pHeight;
SetWidth(pColmunID : Code[10];pWidth : Decimal)
IF (pColmunID <> '') AND (pWidth > 0) THEN
XlWrkSht.Range(pColmunID + FORMAT(1)).ColumnWidth := pWidth;
SetZoom(pZoom : Integer)
XlWrkSht.PageSetup.RightHeader :='';
IF pZoom > 0 THEN
XlWrkSht.PageSetup.Zoom := pZoom;
But it's no longer working in 2018 using dotnet. I could found a function "XlWrkShtWriter.SetColumnWidth" to do the column width and it works.
However there isn't one for row height and zoom. Could anyone give me some advice? Many thanks.
Answers
You can find an example here:
https://forum.mibuso.com/discussion/73152/excel-buffer-with-extended-formatting
You will need to use 2 functions:
- Call SetRowsProperty() from your report
- Add WriteRowsProperties() to WriteSheet function.
Is there any luck that I can also set the default zoom rate?
Try to change code in WriteSheetViews() function.
Now it adds freeze pane to the sheet.
You should get something like that: Zoom is your new global variable