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.

12. August 2024

Erstellen und Installieren des Postgres-Plugins in FastReport .NET

In diesem Artikel wird beschrieben, wie Sie mit dem FastReport .NET-Plugin für den Berichtsdesigner aus Visual Studio über den NuGet-Server eine Verbindung zur Datenbank herstellen.
8. August 2024

Installation von FastReport .NET und ihren Komponenten unter Windows

Schritt für Schritt Anleitung zur Online- und manuellen Installation über den Registrierungscode FastReport .NET und seine Komponenten in Windows.
26. Juli 2024

Aktualisierung von HTMLObject als Plugin für FastReport .NET

Ausführliche Anleitung zur Verwendung des neuen HTMLObject-Plugins, das die Aufteilung des HTML-Doms in FastReport-Berichtsobjekte verwendet.
Fast Reports
  • 800-985-8986 (Englisch, die USA)
  • +4930568373928 (Deutsch)
  • +55 19 98147-8148 (Portugiesisch)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.