Page 1 of 1

excel print setup fit width not correct

PostPosted: Thu Oct 14, 2021 2:36 pm
by pitc
The svyUtils$Excel provides a sheet print setup feature.
I want the excel print to fit in 1 page wide by multiple pages high as needed.
The code I have is:
Code: Select all
   var printSetup = scopes.svyExcelUtils.createPrintSetup();
   printSetup.setLandscape(true);
   printSetup.setPaperSize(scopes.svyExcelUtils.PAPER_SIZE.LETTER_PAPERSIZE);
//   printSetup.setFitHeight(1);// do not set - multiple pages high
   printSetup.setFitWidth(1);// one page wide
   
   scopes.svyExcelUtils.setDefaultPrintSetup(printSetup);


then later after creating a sheet:
Code: Select all
   var sheet = workbook.createSheet(sheet_title);
   
   sheet.setPrintSetup(printSetup);//ensures that the sheet is correctly setup


But the resultant excel file appears to not be one page wide when I print it out.
Is this a bug or do I need something else in set up?

Re: excel print setup fit width not correct

PostPosted: Wed Oct 20, 2021 4:08 am
by pitc
SOLVED:
After much trial and error and researching the web for the same topic I finally found this sequence works:
Code: Select all
   
//in this EXACT order
var ps = sheet.sheet.getPrintSetup();
ps.setFitHeight(0);
ps.setFitWidth(1);


Oh Yes and if you want to see grid lines:
Code: Select all
   
sheet.sheet.setDisplayGridlines(true);//for display
sheet.sheet.setPrintGridlines(true);// for printing


(Yes that is correct: sheet.sheet has methods...