Scale management when printing in Excel

2018-11-05

FastReport .NET 2018.4 version brought quite a few innovations. One of them is the ability to set the scale of the Excel page of the document when printing in the Excel export settings.

You can export the report to Excel in preview mode or from the code of the user application. Let's consider both options.

Export to Excel 2007 from pre-view. For example, I will take a report with a large number of rows and columns - a matrix of 100 by 100. Let’s open the export menu in Excel 2007:

 

At the bottom of the form is the “Print Scaling” option. The default setting is “Actual Size” (No Scaling). Let's make an export and see the Excel document in the view mode when printing:

 

As you can see, the report did not fit one printing page. It will take 6 pages for our matrix.

Let's export the report again. But now, for Print Scaling, we select Fit Sheet on One Page. What will we see in the print mode of an Excel document?

The scale of the document is reduced so that it fits entirely one page. Well, this is a very valuable option. Often we need to print the entire report on one page. It is necessary to select the scale by trial and error.

Let's move on to the next value of the “Print Scaling” option - “Fit All Columns on One Page”. In this case, our example with the matrix will not be the most indicative. As far as you understood, this option allows you to place all data columns on one printing page. In this case, the lines may not fit one page and another one will be generated. But, since our matrix is square, both the columns and the rows will fit on the same printing page.

Therefore, I will generate another 30-by-100 matrix. Let's export it to Excel with the value "Fit All Columns on One Page” of the" Print Scaling "option. Let's see how it looks like in print mode in Excel:

The scale of the document was chosen so that all columns fit in the width of one page. But the lines did not fit, but this is not important for us, because we chose "All columns on one page."

Another value of the option "Scaling when printing" - "All lines on one page." In this case, it is important for us to put all the lines on one page, and whether the columns fit in is not of interest to us. Let's make export to Excel of our matrix 100 by 100. Let's see what happened:

All requirements are met - the lines fit on one page. And only 56 columns fit. For the rest, a second print page was created.

So, we consider 4 document scales when exporting a report to Excel 2007. Now let's see how to use the considered option in the code of the user application:

1
2
3
4
Report report = new Report();
FastReport.Export.OoXML.Excel2007Export exp = new FastReport.Export.OoXML.Excel2007Export();
 exp.PrintFit = FastReport.Export.OoXML.Excel2007Export.PrintFitMode.FitAllColumsOnOnePage;
 report.Export(exp, @"C:\result.html");

 4 values available for PrintMode: NoScaling, FitSheetOnOnePage, FitAllColumsOnOnePage, FitAllRowsOnOnePage.

And for the web report, only one mode of scaling Excel document is available - Place on one page:

1
2
webReport.XlsxPrintFitPage = true;
webReport.ExportExcel2007();

 Thus, we have at our disposal another useful option.

November 20, 2024

Localization and Language Switching in FastReport VCL

FastReport VCL supports 40 languages for interface localization and allows you to change the language on the fly through menus or code, without recompilation.
November 01, 2024

New Features of the FastReport VCL Editor

We are considering new features of the report editor: extension lines, highlighting of intersecting objects, updated report and data trees.
October 30, 2024

Using Styles When Creating Reports in FastReport VCL

The article discusses one of the new features of FastReport VCL — the use of styles and style sheets.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2024 Fast Reports Inc.