We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SetFitToPages back to default

When i use SetFitToPages to show all my data on one page i am not able to back to default afterwards.
The code below generedes two identical pdf fiels where both have all data showing in one page.
Eventhough running SetFitToPages(1,1) should give me the default setup?

  var wb = new Workbook();
  var sheet = wb.Worksheets[0];

  for (int i = 0; i < 50; i++)
    sheet.Cells[i,i].Value = "Data";

  var filename = @"C:\Users\mjp\Desktop\AsposeTestogLeg\Excel\Live1_1.pdf";      

  sheet.PageSetup.SetFitToPages(1, 0);
  var filename2 = @"C:\Users\mjp\Desktop\AsposeTestogLeg\Excel\Live1_0.pdf";


There is a little issue with a line in your code, so your code is wrong. Please change the line of of code:
sheet.PageSetup.SetFitToPages(1, 0);
sheet.PageSetup.SetFitToPages(0, 0);

it will work for your needs.

Please note, if you use the line sheet.PageSetup.SetFitToPages(1, 0);, you are still trying to render fit to page(s) width wise (wide), so you need to set it off as well.

1 Like

Great. You are correct. Though it is confusing that the default values of tall and wide are 1?

No. in MS Excel “Adjust to:” option —> “100%” scaling is the default value set for the page unless you select “Fit to:” option (which is set 1 page wide and 1 page tall). So you my either use the line to set off the options via sheet.PageSetup.SetFitToPages(0, 0); (to get you to defaults) or use sheet.PageSetup.Zoom = 100; to get 100% scaling for getting back to defaults.

Hope, this helps a bit.