This article explains how to export a report to XLS format from Preview (Visual Studio, WinForms, WPF), Document Viewer (Web Platforms), and in code. The article also describes export modes and export options you can specify for the exported XLS file.
Note
Export options listed in this article generate WYSIWYG output. Report layouts with misaligned columns, empty spaces, and misaligned headers and footers might produce merged cells and extra columns/rows in the exported XLS file. Refer to the following section for more details: Merged Cells And Extra Columns/Rows: Troubleshooting. To export data to XLS without exact layout replication, use the Spreadsheet Document API instead of the reporting export engine.
Export from Preview (Visual Studio, WinForms, WPF)
You can export a report from the Visual Studio Preview tab, WinForms Print Preview, and WPF Print Preview. Expand the drop-down list of export formats and select XLS File.
Specify export mode and options in the invoked XLS Export Options dialog and click OK.
Export from Document Viewer (Web Platforms)
You can export a report from ASP.NET Web Forms Document Viewer, ASP.NET MVC Document Viewer, or ASP.NET Core Document Viewer. Specify export options in the Export Options dialog, expand the Export To drop-down list in the toolbar, and select XLS.
Export in Code
Use the XtraReport.ExportToXls or XtraReport.ExportToXlsAsync methods to export a report to XLS format. Specify the path/stream to which the report should be exported as the first argument in these methods. If you specify only the path/stream, the report is exported to XLS format with the default options. To change the default options, do the following:
- If you create a report in code: create a XlsExportOptions object, specify export options for this object, then pass the object to the XtraReport.ExportToXls or XtraReport.ExportToXlsAsync methods as the second argument.
- If you create a report in the Visual Studio Designer: change the options in the Properties panel.
Example
View Example: Export a Report to XLS Format
- Form1.cs
- Form1.vb
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System.Windows.Forms;
using System;
namespace XlsExportExample {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Create a report.
XtraReport report = new XtraReport() {
Name = "Report Example",
Bands = {
new DetailBand() {
Controls = {
new XRLabel() {
Text = "Some content goes here...",
}
}
}
}
};
// Specify export options.
XlsExportOptions xlsExportOptions = new XlsExportOptions() {
ExportMode = XlsExportMode.SingleFile,
ShowGridLines = true,
FitToPrintedPageHeight = true
};
// Specify the path for the exported XLS file.
string xlsExportFile =
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) +
@"Downloads" +
report.Name +
".xls";
// Export the report.
report.ExportToXls(xlsExportFile, xlsExportOptions);
}
}
}
Export Modes
Use the Export Mode option to specify one of the following XLS export modes.
Single File
Exports a report to a file that contains one sheet with all report pages. The report’s page headers, footers, and top/bottom margins appear only once, at the beginning and end of the sheet.
Single File Page-By-Page
Saves every report page as one sheet. The report’s page headers, footers, and top/bottom margins appear on every sheet.
Different Files
Exports a report to multiple files. Each file contains a sheet that corresponds to one report page. Page headers, footers, and top/bottom margins appear on every sheet.
Export Options
The following options are available in the XLS Export Dialog, which you can open from the Visual Studio Print tab, WinForms Print Preview, WPF Print Preview, and in the Export Options dialog of the Document Viewer (Web platforms):
- Page Range
- Sheet Name
- Text Export Mode
- Show Grid Lines
- Export Hyperlinks
- Raw Data Mode
The options below are available only in the Properties panel in the Visual Studio Report Designer, WinForms End-User Report Designer, WPF End-User Report-Designer, …
… and in the Export options dialog of the Document Viewer (Web platforms).
- Image Export Options
- Print Options
- Encryption Options
- Suppress Export Exceptions Options
- Workbook Color Palette Compliance
- Right-to-Left Document
- Ignore Errors
Page Range
The Page Range option specifies the range of pages that should be exported to an XLS file. For example, the “1,3,5-12” range exports pages one, three, and five through twelve.
Sheet Name
Use the Sheet Name option to specify the name of the sheet in the exported XLS file. If you use Single File Page-By-Page mode, a consecutive index is added to the name of each sheet in the exported XLS file.
Text Export Mode
Use the Text Export Mode option to specify one of the following XLS export modes for report data:
-
Value (default)
Exports all data with the same formatting as in the original document. Integer, double, and Boolean values are exported with their original types. All other values are exported as strings. For the XRLabel control, the XlsxFormatString property value is used as a format string. If the property is not specified, the TextFormatString property value is used as a format string.
-
Text
Exports all data as strings.
Show Grid Lines
The Show Grid Lines option specifies whether sheet gridlines are visible in the exported XLS file.
Export Hyperlinks
Use the Export Hyperlinks option to specify whether to include hyperlinks in the exported XLS file. Only absolute URLs of the following types are supported:
URL Type |
Example |
---|---|
Email address |
mailto:office@example.com?subject=Inquiries |
Web page |
https://www.example.com |
File |
file:///D:/Files/Agreement.html |
Raw Data Mode
Enable the Raw Data Mode option to export plain data and ignore images, graphics, font, and appearance settings.
Image Export Options
Enable the Rasterize Images option to rasterize vector images in pictures, charts, and barcodes in the exported XLS file. Use the Rasterization Resolution option to specify image resolution.
Print Options
Enable the Fit To Printed Page Height/Fit To Printed Page Width option to shrink the height/width of the exported document’s printout to one page. Enable both of these options to shrink the width and height of the exported document’s printout to one page.
Encryption Options
Use the Password option to set a password for the exported XLS file. XLS files support ARC4 encryption (except for RC4CryptoAPI). Refer to the following topic for more information: Office Document Cryptography Structure.
Important
Passwords for XLS files are stored as plain text in report definitions. Ensure that only trusted parties have access to report definition files.
Suppress Export Exceptions Options
Use the options below to suppress exceptions that raise if the exported XLS file contains more than 256 columns or 65536 rows:
- Suppress256ColumnsWarning
- Suppress65536RowsWarning
Workbook Color Palette Compliance
Use the WorkbookColorPaletteCompliance property to specify color palette compatibility with different workbook versions.
Right-to-Left Document
If you use right-to-left fonts in a report, enable the Right-to-Left Document option to use the right-to-left layout for sheets in the exported XLS file.
Ignore Errors
Use the Ignore Errors option to specify errors that should be ignored in the exported XLS file.
Limitations
Common
- Values of custom types are not exported to XLS files. If a cell within the exported XLS file contains a value of a custom type, the cell displays the #VALUE! error.
- An XLS cell may contain up to 32,767 characters. If the control’s Text property contains longer text, the text is truncated in the exported XLS file. No errors or warnings are displayed. Refer to the following Microsoft topic for more information: Excel specifications and limits.
- Cross-sheet references work in Single File export only.
Single File Mode
- If a report uses CachedReportSource, changes made in Preview are not included in Single File exports.
- If a report includes a page merged from another document, you cannot export the report as a Single File. The exported file contains only one of the merged reports. As a workaround, use subreports to combine multiple reports into a single document or export each report to a single XLS file, then join these files into one file.
Overlapped Controls
-
Overlapped controls might produce a corrupted layout in the exported XLS file. In the Report Designer, overlapped controls are shown in red. Move the mouse pointer over these controls to show a detailed export warning:
If you create a report in code, use the HasExportWarningControls collection to check if the report contains controls with export warnings.
-
The XRLabel control placed over the XRPictureBox control is exported to an XLS file under the picture.
The BeforePrint Event
If a control is bound to a data source field and the Text Export Mode option is set to Value, data from this field is exported directly to an XLS file. If you modify the control’s Text property value in the BeforePrint event, the changes are not exported to the XLS file. To modify and export the control’s data, use one of the following techniques:
- Assign data to the control’s Value property instead of the Text property in the implemented BeforePrint event.
- Use the EvaluateBinding event instead of BeforePrint. Assign a new value to the e.Value property.
- Set the Text Export Mode option to Text. Note that all values are exported as strings for this mode.
HTML/RTF Export
You can specify HTML content for the XRLabel control and HTML/RTF content for the XRRichText control. Only the following groups of HTML tags and their RTF equivalents are supported in XLS files:
Tag Group |
Tags Example |
---|---|
Text format |
<b>, <i>, <u>, <s> |
Font settings (name, size, and foreground color) |
<font=[font name]> |
Line break |
<br> |
Non-breaking space |
<nbsp> |
Refer to the AllowMarkupText property description for information on XRLabel HTML tags supported in XLS files. See the following topic for details on HTML tags that XRRichText supports: HTML Support Limitations: Supported and Unsupported Tags.
Export Report Groups to Separate XLS Sheets
This section explains how you can export each data group into an individual worksheet. You can leverage the Single File Page By Page export mode if you take a few preparatory steps.
Do the following to export each report group to separate XLS sheets:
-
Modify the report layout to place each group on a new report page. Use one of the following methods to separate the report groups:
- If the groups are stored in one report, use the XRPageBreak control or enable the Band.PageBreak property.
- If each group is stored as a separate report, use the XRSubreport control with the GenerateOwnPages property enabled.
-
Fit the content of each group to one report page. To do this, set the XtraReport.RollPaper property to true.
- Enable Single File Page By Page export mode to export each page of the report to a separate XLS sheet.
- (Optional) Use the XlSheetCreated event to change the default name of each XLS sheet.
Note
You may want these layout changes to be applied only to the XLS export and not to on-screen preview or other export formats. In such cases, we recommend that you create a copy of the report and adjust this copy specifically for XLS export purposes. If you create a report in the Visual Studio Designer, you can customize the report in code.
View Example: Export Report Groups to Separate Excel Sheets
Merged Cells And Extra Columns/Rows: Troubleshooting
Export options listed in this article produce WYSIWYG output. Report layouts with misaligned columns, empty spaces, misaligned headers and footers, and overlapped controls might produce merged cells and extra columns/rows in the exported XLS file. This section describes how you can modify a report layout to resolve these issues.
Misaligned Columns
The image below shows a report with a table whose header’s columns are not aligned with the table cells:
The exported XLS file has the following layout:
Only A, C, E, and G columns are visible. Extra B, D, F, and H columns are added to the exported XLS file. The problem occurs because the table header and the cells in the Detail band are not aligned. The image below shows the borders of the misaligned columns:
To remove extra columns, align header and detail cells horizontally:
Empty Spaces
The image below shows a report with empty spaces between controls:
The exported XLS file has the following layout:
In the image below, cells with exported controls have a yellow background. As you can see, the export generated additional cells to replicate empty spaces between the controls.
To fix this issue, move or resize report controls to eliminate empty space. Use the TextAlignment and Padding properties to adjust text position.
Misaligned Headers And Footers
The image below shows a report with a header in which the control’s borders are not lined up with the report’s table columns.
The exported XLS file has the following layout:
The image below highlights the controls that generate extra columns:
To remove these extra columns, align the controls in the report header and footer to table columns:
Overlapped Controls
The following image shows a report layout with two overlapped labels:
The exported Excel file appears as follows:
You can see that an extra column named B appears in the exported file. To remove this column, modify your report layout such that the controls do not overlap.
After the modification, the exported file does not contain the extra column:
Introduction
SQL Server Reporting Services (SSRS) has multiple options of exporting data into a variety of formats and we will be
discussing the options of exporting SSRS Reports to multiple sheets of excel. In SSRS, there are multiple formats
available to export reports depending on the user’s needs. Microsoft Word, Microsoft Excel, Microsoft PowerPoint,
Tiff file, MHTML (Web Archive), CSV (comma delimited) and XML file with report data are the popular formats that can
be exported from SSRS as shown in the below screenshot.
As you know, every format has its own features. For example, in Microsoft excel there are sheets that are used to
group the data. Excel savvy users prefer to group the data into sheets. The challenge that many users experience is
exporting SSRS reports to multiple sheets of excel.
There are a couple of scenarios of requirements for exporting SSRS Reports to multiple sheets of excel.
-
Different Tablix in Different sheets: In this requirement, there will be multiple tables/tablixes that you need
to export them to different sheets -
Same Tablix in Different sheets: In this requirement, the same tablix will have different groups of data. For
example, sales tablix will have product categories of Bikes, Components, Clothing, and Accessories. This data
set may require exporting SSRS Reports to multiple sheets of Excel depending on these categories. In other
words, sheets are dynamic as they depend on the data set
Scenario 1
First of all, let us create a sample report in order to demonstrate the feature of exporting SSRS Reports to
multiple sheets of Excel. Let us launch the Visual Studio or SQL Server Data tool (SSDT) and create a Reporting
server project. Then let us add a report to the newly created SSRS project. Next, we will create a connection by
pointing out the AdventureWorksDW sample database.
Let us create two data sets where one has the bikes data and the other data set has data of clothing. Following is
the query for one data set by joining FactInternetSales, DimProduct, DimProductCategory and DimProductSubcategory.
SELECT TOP (5) DimProductSubcategory.EnglishProductSubcategoryName, DimProductCategory.EnglishProductCategoryName, DimProduct.EnglishProductName, FactInternetSales.SalesAmount, FactInternetSales.TaxAmt,
FactInternetSales.Freight, DimDate.FullDateAlternateKey, FactInternetSales.SalesOrderNumber
FROM FactInternetSales INNER JOIN
DimProduct ON FactInternetSales.ProductKey = DimProduct.ProductKey INNER JOIN
DimProductSubcategory ON DimProduct.ProductSubcategoryKey = DimProductSubcategory.ProductSubcategoryKey INNER JOIN
DimProductCategory ON DimProductSubcategory.ProductCategoryKey = DimProductCategory.ProductCategoryKey INNER JOIN
DimDate ON FactInternetSales.ShipDateKey = DimDate.DateKey
WHERE (DimProductCategory.EnglishProductCategoryName = ‘Bikes’)
This is configured as shown in the following screenshot:
Similarly, another data set is created for the clothing and two tables are included as follows.
Please note that in order to demonstrate, only the top five records are retrieved and the following screen shows the
output of the report.
When this is exported to Microsoft excel, typically this will be exported to one sheet whereas the requirement is,
exporting SSRS Reports to multiple sheets of Excel. Further, Sheet names should be Bikes and Clothing.
There are three tasks in order to create multiple sheets.
- Creating a Page Break after the Bikes table
- Naming the Sheets with appropriate names
- Repeat the headings on every page
Three different configurations have to be done for this and let us do this configuration one by to implement
exporting SSRS Reports to Multiple sheets of Excel.
To add a page break, go to the properties of the first table or the tablix as shown below.
By selecting the Add a page break after, you are adding a page break after this table.
As you know, by default, sheets will be named as Sheet1, Sheet2 etc. However, we would like the name them with a
proper name. For example, we would like to name the sheets as Bikes and Clothing instead of Sheet1, Sheet2.
By selecting the relevant tablix and changing the PageName to Bikes will change the sheet name to Bikes as shown in
the below screenshot.
Similarly, the page name of the next tablix is named Clothing as shown in the below screenshot.
The last option is to repeat the heading on every page. There are several options for that and the very basic option
is, configure the RepeatWith property of the Header text box.
The above configuration shows that the header is repeated with the Tablix3. However, if there are more than two
pages, then this option will not work. Instead, we can add a report header by right-clicking and add a page header
and configure as shown in the following screenshot.
Now you are done with the configuration and let us verify this.
When you preview the report, you will see that both tablixs have appeared in two different pages alone with the
header. When you export it to the excel, you will see that data is in separate sheets with the relevant names.
Further, you will see that you will have the header on both sheets.
This is shown in the following screenshot.
You will see that there are two sheets with appropriate names instead of default sheet names.
Scenario 2
If you look at the above example, you will see that category is kind of hardcoded. In case, there are new
categories, you need to add them to another tablix along with a new query which will not be a good option.
Therefore, we need the option of exporting SSRS Reports to multiple sheets of excel for dynamic groups.
Let us see the report without any page breaks as shown in the below screenshot.
When you export this to Microsoft Excel, we should see three sheets with relevant names. If there are new categories
added later, those should be seen in a new sheet. This means sheets should be dynamic.
First of all, let us create a grouping with the category name by right-clicking the tablix and adding to
We have enabled the Add group header option so that we can use it to repeat the column headers
later. Then move the tablix headers to the group headers and you will the following report after viewing it.
Next is to include the page break to the included groups. To do that, go to the properties of the groups from the
following option.
In the Page Breaks option, choose the Between each instance of a group as shown in the below image.
Now we need to provide the sheet name for when exporting to the Multiple sheets of Excel in SSRS.
Go to the properties of the group and go to Group -> PageName as shown in the below screenshot.
Since the sheet name is dynamic, it has to be an Expression. In the expression property page, you need to provide
the name of the sheet by combining the dataset fields as shown in the below screenshot.
Now everything is set and let us verify whether we get the data in when Exporting SSRS reports to Multiple Sheets of
Excell.
You will observe that when exporting to multiple sheets in Excel, it can be configured dynamically in SSRS.
Conclusion
SQL Server Reporting Services is one of the most common reporting tools used in many organizations by many users.
SSRS has the option of exporting reports to many formats and Microsoft Excel is the most common format that users
use. However, since Microsoft Excel has the Sheet feature, users would like exporting SSRS Reports to multiple
sheets of excel.
We looked at two options for creating multiple sheets in Microsoft Excel. Initially, we looked at how to create two
separate tablixes into multiple sheets and name the sheets accordingly. Next, we looked at the exporting SSRS Report
to multiple sheets of excel in dynamic nature. In that, we used the Grouping feature of the Tablix.
- Author
- Recent Posts
Dinesh Asanka is MVP for SQL Server Category for last 8 years. He has been working with SQL Server for more than 15 years, written articles and coauthored books. He is a presenter at various user groups and universities. He is always available to learn and share his knowledge.
View all posts by Dinesh Asanka
title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | ms.custom |
---|---|---|---|---|---|---|---|---|
Export a paginated report to Microsoft Excel (Report Builder) |
In Report Builder, the Excel rendering extension renders a paginated report to the Office Open XML format to use with Microsoft Excel. |
maggiesMSFT |
maggies |
03/24/2023 |
reporting-services |
report-builder |
conceptual |
updatefrequency5 |
Export a paginated report to Microsoft Excel (Report Builder)
[!INCLUDEssrs-appliesto] [!INCLUDE ssrs-appliesto-ssrs-rb] [!INCLUDE ssrs-appliesto-pbi-rb] [!INCLUDE ssrb-applies-to-ssdt-yes]
The Excel rendering extension renders a paginated report to the [!INCLUDEofprexcel] format (.xlsx). With the Excel rendering extension, the width of columns in Excel more accurately reflects the width of columns in reports.
The format is Office Open XML. The content type of files generated by this renderer is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet and the file extension is .xlsx.
You can change some default settings for this renderer by changing the device information settings. For more information, see Excel Device Information Settings.
See Export Reports (Report Builder and SSRS) for details on how to export to Excel.
[!IMPORTANT]
When you define a parameter of type String, the user is presented with a text box that can take any value. If a report parameter is not tied to a query parameter and the parameter values are included in the report, it is possible for a report user to type expression syntax, script, or a URL into the parameter value, and render the report to Excel. If another user then views the report and clicks the rendered parameter contents, the user may inadvertently execute the malicious script or link.To mitigate the risk of inadvertently running malicious scripts, open rendered reports only from trusted sources. For more information about securing reports, see Secure Reports and Resources.
Excel Limitations
[!INCLUDEofprexcel] places limitations on exported reports due to the capabilities of Excel and its file formats. The most significant are the following:
-
The maximum column width is limited to 255 characters or 1726.5 points. The renderer does not verify that the column width is less than the limit.
-
The maximum number of characters in a cell is limited to 32,767. If this is exceeded, the renderer displays an error message.
-
The maximum row height is 409 points. If the contents of the row cause the row height to increase beyond 409 points, the Excel cell shows a partial amount of text up to 409 points. The rest of the cell contents is still within the cell (up to Excel’s max number of characters of 32,767).
-
Because the maximum row height is 409 points, if the defined height of the cell in the report is something larger than 409 points, Excel splits the cell contents into multiple rows.
-
The maximum number of worksheets is not defined in Excel, but external factors, such as memory and disk space, might cause limitations to be applied.
-
In outlines, Excel permits up to seven nested levels only.
-
If the report item that controls whether another item is toggled is not in the previous or next row or column of the item being toggled, the outline is disabled also.
For more details about Excel limitations, see Excel specifications and limits.
Sizes of Excel 2003 (.xls) Files
[!IMPORTANT]
The [!INCLUDEofprexcel] 2003 rendering extension is deprecated. For more information, see Deprecated Features in SQL Server Reporting Services in SQL Server 2016.
When reports are first exported and saved to Excel 2003, they do not benefit from the file optimization that Excel automatically applies to its *.xls workbook files. The larger file size can cause problems for e-mail subscriptions and attachments. To reduce the size of the *.xls files for exported reports, open the *.xls files and then resave the workbooks. Resaving the workbooks typically reduces their file sizes by 40 to 50 percent.
[!NOTE]
In Excel 2003, approximately 1000 characters are displayed in an Excel cell on the worksheet but up to the maximum number of characters can be edited in the formula bar. This limitation does not apply to current (.xlsx) Excel files.
Text Boxes and Text
The following limitations apply to text boxes and text:
-
Text box values that are expressions are not converted to Excel formulas. The value of each text box is evaluated during report processing. The evaluated expression is exported as the contents of each Excel cell.
-
Text boxes are rendered within one Excel cell. Font size, font face, decoration, and font style are the only formatting that is supported on individual text within an Excel cell.
-
The text effect «Overline» is not supported in Excel.
-
Excel adds a default padding of approximately 3.75 points to the left and right sides of cells. If a text box’s padding settings are less than 3.75 points and is just barely wide enough to accommodate the text, the text may wrap in Excel.
[!NOTE]
To work around this issue, increase the width of the text box in the report.
Images
The following limitations apply to images:
-
Background images for report items are ignored because Excel does not support background images for individual cells.
-
The Excel rendering extension only supports the background image of the report body. If a report body background image is displayed in the report, the image is rendered as a worksheet background image.
Rectangles
The following limitation applies to rectangles.
- Rectangles in report footers are not exported to Excel. However, rectangles in the report body, tablix cells, and so forth are rendered as a range of Excel cells.
Report Headers and Footers
The following limitations apply to report headers and footers:
-
Excel headers and footers support a maximum of 256 characters including markup. The rendering extension truncates the string at 256 characters.
-
[!INCLUDEssRSnoversion] does not support margins on report headers and footers. When exported to Excel, these margin values are set to zero and any header or footer that contains multiple rows of data might not print multiple rows, depending on the printer settings.
-
Text boxes in a header or footer maintain their formatting but not their alignment when exported to Excel. This occurs because leading and trailing spaces are trimmed when the report is rendered to Excel.
Merging Cells
The following limitation applies to merging cells:
- If cells are merged, word-wrap does not work correctly. If any merged cells exist on a row where a text box is rendered with the AutoSize property, autosize will not work.
The Excel renderer is primarily a layout renderer. Its goal is to replicate the layout of the rendered report as closely as possibly in an Excel worksheet and consequently cells might be merged in the worksheet to preserve the report layout. Merged cells can cause problems because the sort functionality in Excel requires cells to be merged in a very specific way for sort to work properly. For example, Excel requires that the ranges of merged cells have the same size in order to be sorted.
If it is important that reports exported to Excel worksheets can be sorted, then the following can help you reduce the number of merged cells in your Excel worksheets, which is the common cause for difficulties with Excel sort functionality.
-
Not aligning items left and right is the most common cause of merged cells. Make sure the left and right edges of all report items line up with one another. Making items align and the same width will solve the problem in the majority of cases.
-
Although you align all items precisely, you might find in some rare cases that some columns continue to be merged. This could be caused by internal unit conversion and rounding when the Excel worksheet is rendered. In the report definition language (RDL), you can specify position and size in different measurement units such as inches, pixels, centimeters, and points. Internally the Excel uses points. To minimize conversion and the potential inaccuracy of rounding when converting inches and centimeters to points, consider specifying all measurements in whole points for the most direct results. One inch is 72 points.
Report Row Groups and Column Groups
Reports that include row groups or column groups contain empty cells when exported to Excel. Imagine a report that groups rows on commute distance. Each commute distance can contain more than one customer. The following picture shows the report.
When the report is exported to Excel, the commute distance appears only in one cell of the Commute Distance column. Depending on the alignment of the text in the report (top, middle, or bottom) the value is in the first, middle, or last cell. The other cells are empty. The Name column that contains customer names has no empty cells. The following picture shows the report after it is exported to Excel. The red cell borders were added for emphasis. The gray boxes are the empty cells. (Neither the red lines nor the gray boxes are part of the exported report.)
Reports with row groups or column groups require modification after exporting to Excel and before you can display the exported data in a PivotTable. You must add the group value to cells in which they are missing. Thus, the worksheet becomes a flat table with values in all cells. The following picture shows the updated worksheet.
So if you create a report for the specific purpose of exporting it to Excel for further analysis of the report data, consider not grouping on rows or columns in your report.
Excel Renderer
Current (.xlsx) Excel File Renderer
In [!INCLUDEssNoVersion] [!INCLUDEssRSnoversion], the default Excel renderer is the version compatible with current (.xlsx) [!INCLUDEofprexcel] files. This is the Excel option on the Exporting menus in the [!INCLUDEssRSnoversion] web portal and SharePoint list.
When you use the default Excel renderer, instead of the earlier Excel 2003 (.xls) renderer, you can install the Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint to allow earlier versions of Excel to open the files that are exported.
Excel 2003 (.xls) Renderer
[!IMPORTANT]
The [!INCLUDEofprexcel] 2003 rendering extension is deprecated. For more information, see Deprecated Features in SQL Server Reporting Services in SQL Server 2016.
The earlier version of the Excel renderer, compatible with Excel 2003, is now named Excel 2003 and is listed on menus using that name. The content type of files generated by this renderer is application/vnd.ms-excel and the file name extension of files is .xls.
By default, the Excel 2003 menu option is not visible. An administrator can make it visible under certain circumstances by updating the RSReportServer configuration file. To export reports from [!INCLUDEssBIDevStudioFull] using the Excel 2003 renderer, you update the RSReportDesigner configuration file.
The Excel 2003 menu option extension is never visible in the following scenarios:
-
Report Builder in disconnected mode and you preview a report in Report Builder. Because the RSReportServer configuration file resides on the report server, the tools or products from where you export reports must be connected to a report server to read the configuration file.
-
Report Viewer Web Part in local mode and the SharePoint farm is not integrated with a [!INCLUDEssRSnoversion] report server. For more information, see Local Mode vs. Connected Mode Reports in the Report Viewer (Reporting Services in SharePoint Mode)
If the Excel 2003 menu option renderer is configured to be visible, both the Excel and Excel 2003 options are available in the following scenarios:
-
[!INCLUDEssRSnoversion] web portal native mode.
-
SharePoint site when Reporting Services is installed in SharePoint integrated mode.
-
[!INCLUDEssBIDevStudioFull] and you preview reports.
-
Report Builder connected to a report server.
-
The Report Viewer Web Part in remote mode.
The following XML shows the elements for the two Excel rendering extensions in the RSReportServer and RSReportDesigner configuration files:
<Extension Name="EXCELOPENXML" Type="Microsoft.ReportingServices.Rendering.ExcelOpenXmlRenderer.ExcelOpenXmlRenderer,Microsoft.ReportingServices.ExcelRendering"/>
<Extension Name="EXCEL" Type="Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer,Microsoft.ReportingServices.ExcelRendering" Visible="false"/>
The EXCELOPENXML extension defines the Excel renderer for current (.xlsx) Excel files. The EXCEL extension defines the Excel 2003 version. Visible = "false"
indicates the Excel 2003 renderer is hidden. For more information, see RsReportServer.config Configuration File and RSReportDesigner Configuration File.
Differences Between the current (.xlsx) Excel and Excel 2003 Renderers
Reports, rendered by using the current (.xlsx) Excel or the Excel 2003 renderers are typically identical and only under rare circumstances will you notice differences between the two formats. The following table compares the Excel and the Excel 2003 renderers.
Property | Excel 2003 | Current Excel |
---|---|---|
Maximum columns per worksheet | 256 | 16,384 |
Maximum rows per worksheet | 65,536 | 1,048,576 |
Number of colors allowed in a worksheet | 56 (palette)
If more than 56 colors are used in the report, the rendering extension matches the required color to one of the 56 colors already available in the custom palette. |
Approximately 16 million (24-bit color) |
ZIP compressed files | None | ZIP compression |
Default font family | Arial | Calibri |
Default font size | 10pt | 11pt |
Default row height | 12.75 pt | 15 pt |
Because the report explicitly sets the row height, the default row height affects only rows that are sized automatically upon export to Excel.
Report Items in Excel
Rectangles, subreports, the report body, and data regions are rendered as a range of Excel cells. Text boxes, images, and charts, data bars, sparklines, maps, gauges, and indicators must be rendered within one Excel cell, which might be merged depending on the layout of the rest of the report.
Images, charts, sparklines, data bars, maps, gauges, indicators, and lines are positioned within one Excel cell but they sit on top of the cell grid. Lines are rendered as cell borders.
Charts, sparklines, data bars, maps, gauges, and indicators are exported as pictures. The data they depict, such as the value and member labels for a chart, is not exported with them and is not available in the Excel workbook unless it is included in a column or row in a data region within a report.
If you want to work with chart, sparkline, data bar, maps, gauge, and indicator data, export the report to a .csv file or generate Atom-compliant data feeds from the report. For more information, see Exporting to a CSV File (Report Builder and SSRS) and Generating Data Feeds from Reports (Report Builder and SSRS).
Page Sizing
The Excel rendering extension uses the page height and width settings to determine what paper setting to define in the Excel worksheet. Excel tries to match the PageHeight and PageWidth property settings to one of the most common paper sizes.
If no matches are found, Excel uses the default page size for the printer. Orientation is set to Portrait if the page width is less than the page height; otherwise, orientation is set to Landscape.
Worksheet Tab Names
When you export a report to Excel, the report pages that were created by page breaks are exported to different worksheets. If you provided an initial page name for the report, each worksheet of the Excel workbook will have this name by default. The name appears on the worksheet tab. However, since each worksheet in a workbook must have a unique name, an integer starting at 1 and incremented by 1 is appended to the initial page name for each additional worksheet. For example, if the initial page name is Sales Report by Fiscal Year, the second worksheet would be named Sales Report by Fiscal Year1, the third one Sales Report by Fiscal Year2, and so forth.
If all report pages created by page breaks provide new page names, each worksheet will have the associated page name. However, these page names might not be unique. If page names are not unique, the worksheets are named the same way as initial page names. For example, if the page name of two groups is Sales for NW, one worksheet tab will have the name Sales for NW, and the other Sales for NW1.
If the report provides neither an initial page name, nor page names related to page breaks, the worksheet tabs will have the default names Sheet1, Sheet2, and so forth.
Reporting Services provides properties to set on reports, data regions, groups, and rectangles to help you create reports that can be exported to Excel in a way that you want. For more information, see Pagination in Reporting Services (Report Builder and SSRS).
Document Properties
The Excel renderer writes the following metadata to the Excel file.
Report Element properties | Description |
---|---|
Created | Date and time of report execution as an ISO date/time value. |
Author | Report.Author |
Description | Report.Description |
LastSaved | Date and time of report execution as an ISO date/time value. |
Page Headers and Footers
Depending on the Device Information SimplePageHeaders setting, the page header can be rendered in two ways: the page header can be rendered at the top of each worksheet cell grid, or in the actual Excel worksheet header section. By default, the header is rendered to the cell grid on the Excel worksheet.
The page footer is always rendered to the actual Excel worksheet footer section, regardless of the value of the SimplePageHeaders setting.
Excel header and footer sections support a maximum of 256 characters, including markup. If this limit is exceeded, the Excel renderer removes markup characters starting at the end of the header and/or footer string to reduce the number of total characters. If all markup characters are removed and the length still exceeds the maximum, the string is truncated starting from the right.
SimplePageHeader Settings
By default, the Device Information SimplePageHeaders setting is set to False; therefore, the page headers are rendered as rows in the report on the Excel worksheet surface. The worksheet rows that contain the headers become locked rows. You can freeze or unfreeze the pane in Excel. If the Print Titles option is selected, these headers are automatically set to print on every worksheet page.
The page header repeats at the top of every worksheet in the workbook except the document map cover sheet if the Print Titles option is selected on the Page Layout tab in Excel. If the Print on first page or the Print on last page option is not selected in the Report Header Properties or Report Footer Properties dialog boxes, the header will not be added to the first or last page respectively.
Page footers are rendered in the Excel footer section.
Because of Excel limitations, text boxes are the only type of report item that can be rendered in the Excel header/footer section.
Interactivity
Some interactive elements are supported in Excel. The following is a description of specific behaviors.
Show and Hide
[!INCLUDEofprexcel] has limitations with how it manages hidden and displayed report items when they are exported. Groups, rows, and columns that contain report items that can be toggled are rendered as Excel outlines. Excel creates outlines that expand and collapse rows and columns across the entire row or column which can cause the collapse of report items that are not intended to be collapsed. In addition, Excel’s outlining symbols can become cluttered with overlapping outlines. To address these issues, the following outlining rules are applied when using the Excel rendering extension:
-
The report item in the top-left corner that can be toggled can continue to be toggled in Excel. Report items that can be toggled and share vertical or horizontal space with the report item that can be toggled in the top-left corner cannot be toggled in Excel.
-
To determine whether a data region will be collapsible by rows or columns, the position of the report item that controls the toggling and the position of the report item that is toggled are determined. If the item controlling the toggling appears before the item to be toggled, the item is collapsible by rows. Otherwise, the item is collapsible by columns. If the item controlling the toggling appears beside and above the area to be toggled equally, the item is rendered with row collapsible by rows.
-
To determine where the subtotals are placed in the rendered report, the rendering extension examines the first instance of a dynamic member. If a peer static member appears immediately above it, the dynamic member is assumed to be the subtotals. Outlines are set to indicate that this is summary data. If there are no static siblings of a dynamic member, the first instance of the instance is the subtotal.
-
Due to an Excel limitation, outlines can be nested up to 7 levels only.
Document Map
If any document map labels exist in the report, a document map is rendered. The document map is rendered as an Excel cover worksheet inserted at the first tab position in the workbook. The worksheet is named Document map.
The text displayed in the document map is determined by the report item’s or group’s DocumentMapLabel property. Document map labels are listed in the order that they appear in the report, starting at the first row, in the first column. Each document map label cell is indented the number of levels deep it appears in the report. Each level of indentation is represented by placing the label in a subsequent column. Excel supports up to 256 levels of outline nesting.
The document map outline is rendered as a collapsible Excel outline. The outline structure matches the nested structure of the document map. The expand and collapse state of the outline starts at the second level.
The root node of the map is the report name, the <reportname>.rdl, and it is not interactive. The document map links font is Arial, 10pt.
Drillthrough Links
Drillthrough links that appear in text boxes are rendered as Excel hyperlinks in the cell in which the text is rendered. Drillthrough links for images and charts are rendered as Excel hyperlinks on the image when rendered. When clicked, the drillthrough link opens the client’s default browser and navigates to the HTML view of the target.
Hyperlinks
Hyperlinks that appear in text boxes are rendered as Excel hyperlinks in the cell in which the text is rendered. Hyperlinks for images and charts are rendered as Excel hyperlinks on the image when rendered. When clicked, the hyperlink opens the client’s default browser and navigates to the target URL.
Interactive Sorting
Excel does not support interactive sort.
Bookmarks
Bookmark links in text boxes are rendered as Excel hyperlinks in the cell in which the text is rendered. Bookmark links for images and charts are rendered as Excel hyperlinks on the image when rendered. When clicked, the bookmark goes to the Excel cell in which the bookmarked report item is rendered.
Changing Reports at Run-Time
If a report must render to multiple formats and it is not possible to create a report layout that renders the way you want in all required formats, then you might consider using the value in the RenderFormat built-in global to conditionally change the report appearance at run time. This way you can hide or show report items depending on the renderer used to get the best results in each format. For more information, see Built-in Globals and Users References (Report Builder and SSRS).
Troubleshoot export to Excel
Export to Excel or Word fails when using Virtual Service Account and Execution Account
The workaround for this issue is to give Read permission to the Execution account for the described registry entry under the Virtual User Account branch, and restart the computer. For example, one possible registry entry is HKEY_USERSS-1-5-80-4050220999-2730734961-1537482082-519850261-379003301SoftwareMicrosoftAvalon.Graphics
.
See Also
Pagination in Reporting Services (Report Builder and SSRS)
Rendering Behaviors (Report Builder and SSRS)
Interactive Functionality for Different Report Rendering Extensions (Report Builder and SSRS)
Rendering Report Items (Report Builder and SSRS)
Tables, Matrices, and Lists (Report Builder and SSRS)
I’m currently building a MS Reporting Services Report that gets rendered to excel. I’m trying to figure out how to set up the report so that it creates multiple Worksheets (Tabs) of the data on the report. I understand that entering a page break in the report gives you a new worksheet, however, is there a way to name each tab instead of it default to (worksheet 1, worksheet 2) etc.
How can this be done?
user
10.9k6 gold badges23 silver badges83 bronze badges
asked Jan 20, 2009 at 20:10
1
To late for the original asker of the question, but with SQL Server 2008 R2 this is now possible:
Set the property «Pagebreak» on the tablix or table or other element to force a new tab, and then set the property «Pagename» on both the element before the pagebreak and the element after the pagebreak. These names will appear on the tabs when the report is exported to Excel.
Read about it here: http://technet.microsoft.com/en-us/library/dd255278.aspx
answered Nov 30, 2010 at 8:56
Here are screenshots for SQL Server 2008 R2, using SSRS Report Designer in Visual Studio 2010.
I have done screenshots as some of the dialogs are not easy to find.
1: Add the group
2: Specify the field you want to group on
3: Now click on the group in the ‘Row Groups’ selector, directly below the report designer
4: F4 to select property pane; expand ‘Group’ and set Group > PageBreak > BreakLocation = ‘Between’, then enter the expression you want for Group > PageName
5: Here is an example expression
Here is the result of the report exported to Excel, with tabs named according to the PageName expression
answered Jan 15, 2014 at 16:15
EdwardEdward
7,9612 gold badges36 silver badges43 bronze badges
As @huttelihut pointed out, this is now possible as of SQL Server 2008 R2 — Read More Here
Prior to 2008 R2 it does’t appear possible but MSDN Social has some suggested workarounds.
answered Jan 20, 2009 at 20:30
cgreenocgreeno
31.7k7 gold badges66 silver badges86 bronze badges
2
The solution from Edward worked for me.
If you want the whole tablix on one sheet with a constant name, specify the PageName in the tablix’s Properties. If you set the PageName in the tablix’s Properties, you can not use data from the tablix’s dataset in your expression.
If you want rows from the tablix grouped into sheets (or you want one sheet with a name based on the data), specify the PageName in the Group Header.
answered Jan 29, 2014 at 18:48
AverageJonAverageJon
711 silver badge2 bronze badges
1
I found a simple way around this in 2005. Here are my steps:
- Create a string parameter with values ‘Y’ and ‘N’ called ‘PageBreaks’.
- Add a group level above the group (value) which was used to split the data to the multiple sheets in Excel.
- Inserted into the first textbox field for this group, the expression for the ‘PageBreaks’ as such…
=IIF(Parameters!PageBreaks.Value="Y",Fields!DISP_PROJECT.Value,"")
Note: If the parameter =’Y’ then you will get the multiple sheets for each different value.
Otherwise the field is NULL for every group record (which causes only one page break at the end). - Change the visibility hidden value of the new grouping row to ‘True’.
- NOTE: When you do this it will also determine whether or not you have a page break in the view, but my users love it since they have the control.
agf
169k42 gold badges286 silver badges236 bronze badges
answered Aug 10, 2011 at 16:43
koderkoder
211 bronze badge
Put the tab name on the page header or group TableRow1 in your report so that it will appear in the «A1» position on each Excel sheet. Then run this macro in your Excel workbook.
Sub SelectSheet()
For i = 1 To ThisWorkbook.Sheets.Count
mysheet = "Sheet" & i
On Error GoTo 10
Sheets(mysheet).Select
Set Target = Range("A1")
If Target = "" Then Exit Sub
On Error GoTo Badname
ActiveSheet.Name = Left(Target, 31)
GoTo 10
Badname:
MsgBox "Please revise the entry in A1." & Chr(13) _
& "It appears to contain one or more " & Chr(13) _
& "illegal characters." & Chr(13)
Range("A1").Activate
10
Next i
End Sub
answered Jun 15, 2011 at 12:25
Group your report data based on the category that you want your sheets to be based on. Specify that you want that grouping to start a new page for every new category. Each page becomes a new worksheet in the Excel workbook.
Note: I use SQL Server 2003 and Excel 2003.
answered Jul 13, 2010 at 15:12
On the group press F4 and look for the page name, on the properties and name your page this should solve your problem
answered Mar 14, 2013 at 10:54
GurruGurru
1,9833 gold badges16 silver badges20 bronze badges
Do you need to share your report built in Salesforce with external stakeholders? Or you simply want to visualize your Salesforce data using some external dataviz tool, such as Tableau? There are many reasons why you might want to export a Salesforce report to Excel but the options are quite limited. Read on to find out which tool or solution works best for you.
Export Salesforce report to Excel – methods to consider
- Manually export Salesforce report to Excel or CSV – this is the native functionality that allows you to manually download Salesforce reports to Excel. You can export formatted reports as Excel files or the raw data as Excel and CSV files.
- Schedule export of Salesforce data to build custom reports in a spreadsheet – this is the approach for custom reporting. You can automate exports of specific data entities to Google Sheets or Excel. Based on this data, you can create a custom report or dashboard, which will update automatically with every data refresh.
- Export Salesforce reports via the Salesforce API – this is an advanced approach, which may require coding skills to extract data via the Salesforce API. Alternatively, you can use the JSON to Excel connector. This will let you avoid any coding, but you’ll need to map the exported data in Excel.
We’re going to review each section separately. However, if you already know which of these options to export reports from Salesforce to Excel would work best for you, you can skip right to it.
How to export Salesforce report to Excel natively
We’ll check out the flow separately for each Salesforce UI version.
Note: To export reports from Salesforce, a user must have the ‘Export Reports’ permission.
Related Posts
Export Salesforce report to Excel in Lightning Experience
- Go to the Reports tab and open the report you want to export.
- Click the Edit drop-down menu on the right side of your Salesforce report and select Export.
- Select the format for export Salesforce report to Excel
- Formatted Report is available for export only as XLSX Excel file
- Details Only is available for export as XLSX or XLS file, as well as CSV
- Click Export – the file with your Salesforce report will be downloaded to your device.
Here is an example of a New Opportunity Trends Report exported formatted from Salesforce Lightning experience:
Salesforce report export in Salesforce Classic
- Go to the Reports tab and open the report you want to export.
In Salesforce Classic, reports do not have an Export button with exporting formats. You can choose them right away with the following buttons:
- Printable View – to export the formatted report in XLS format
- Export Details – to export the report’s data in XLS or CSV
For example, here is what a New Opportunity Trends Report looks like if exported as Printable View from Salesforce classic:
The difference between Formatted Export (Lightning Experience) and Printable View (Salesforce Classic) is obvious.
At the same time, there is no difference if you export report details from both Salesforce UI versions:
This is how you can export a Salesforce report to Excel. Also, check out the restrictions associated with this action.
Salesforce reports for Excel export limitations
- Up to 5 reports at once.
- Unlimited number of rows and columns for Details Only reports in XLS or CSV formats.
- Up to 100,000 rows and 100 columns for Formatted Reports or Details Only in XLSX format.
- Historical trending reports are not available for export.
- Joined reports can include a maximum of 2,000 rows and are available for export only as Formatted Report.
Can I auto export Salesforce report to Excel?
Unfortunately, Salesforce does not allow you to export Salesforce reports to Excel on a schedule. This is rather frustrating because automation would allow you to save much of the time for your reporting tasks.
However, there is always a solution. Below we’ll introduce a few methods so you can set up automation for your Salesforce reports.
How to export Salesforce report to Excel automatically
In the blog post Salesforce Export Data, we explained how you can schedule exports of data from Salesforce to Excel or Google Sheets. For this, you need Coupler.io, an iPaaS solution that extracts data from apps, such as Airtable, Google Sheets, and so on, and loads it to a chosen destination on a schedule.
Coupler.io provides a dedicated Salesforce integration, which allows you to auto export a bunch of data entities including Contacts, Orders, Opportunities, and many more. Reports are also on the list of exportable data entities, but it only exports a list of reports.
Nevertheless, the method we suggest here is as follows:
- Export raw Salesforce data required for the report
- Build a custom report in Excel and link the exported data to it
This will let you automate reporting on a schedule like every hour or every 15 minutes. Let’s now look at how this works.
Example of how you can connect Salesforce report to Excel
As an example, let’s take the New Opportunity Trends Report that we’ve recently exported manually. For this report, we’ll need information about Opportunity History. To export this data, sign up to Coupler.io, click Add new importer and configure the integration.
Set up source
- Select Salesforce as a source application.
- Connect your Salesforce account. You will need to log in to Salesforce if you have not already.
- Select Opportunity History as a data entity from a drop down list.
Note: You can filter the data to export from Salesforce to Excel using the Advanced filters section, for example, like this:
Jump to the destination setup.
Set up destination
- Select Excel as a destination app from the drop-down list.
- Connect your Microsoft account.
- Select a workbook stored on your OneDrive, as well as the worksheet where to load the Salesforce data. Optionally, you can type in a name to create a new sheet.
Here is what the destination configuration may look like.
Click Save and Run to load Salesforce data to your Excel workbook. Here is how it looks:
This is just raw data, which you can convert into a report as you wish.
Build a report based on the Salesforce data exported to Excel
In our example, we inserted a Pivot table to get the format we need.
Here are the steps we took:
- Added a new column with the End of the Month formula to convert values from the CloseDate column.
- Inserted a pivot table with the following fields:
- Rows: StageName
- Columns: End of Month
- Values: Sum of Amount
And here is what our custom report looks like compared to the New Opportunity Trends Report that we exported manually from Salesforce to Excel.
The main benefit of the custom report is that it will be updated automatically with every data refresh that you set up in Coupler.io. So, you can use this method for not only reporting but also other tasks, for example, creating a Salesforce backup copy.
Salesforce schedule report Excel
- In your Salesforce to Excel integration, toggle on the Automatic data refresh feature.
- Then configure the desired frequency for automated exports.
And that’s it! Coupler.io will automatically update data from Salesforce in Excel, so the values in the pivot table will be automatically updated as well.
Note: Pivot table is just an example that we used here. You can create custom reports using Excel functions, Power Query, charts, and other features.
Link Salesforce report to Excel using the Salesforce API
The last option on our list of solutions for exporting Salesforce reports to Excel is the Salesforce REST API. We’ve covered this in more detail in our article on Salesforce Data Export. To do this, you’ll need to complete the following steps:
- Create a Connected App in Salesforce
- Get an access token
With an access token, you can send a GET request to the following API URL:
curl "{instance-URL}/services/data/{api_version}/analytics/reports/{report-ID} -H "Authorization: Bearer {access_token}"
where:
{instance-URL}
is the instance URL, which you obtained along with the access token, for example,
https://zrecords-dev-ed.my.salesforce.com
{api_version}
is the version of the Salesforce API{access_token}
is your access token{report-ID}
is the Id of your Salesforce report. You can learn the report ID by opening the report and checking the URL bar.
This step is more technical since it requires you to work with the Salesforce API documentation, as well as write a script to extract data and map it into your Excel file.
Alternatively, you can learn how to connect API to Excel without coding.
Do you need the no-code integration for exporting Salesforce reports to Excel?
It’s believed that wishing upon a shooting star makes the wish come true:) Coupler.io suggests that you don’t wait for this moment, but simply let us know whether you need to have the option for exporting reports to Excel or Google Sheets. Fill out this form to submit your request. Many of our integrations came out thanks to the active users who expressed their interest in particular sources. Good luck with your data!
-
A content manager at Coupler.io whose key responsibility is to ensure that the readers love our content on the blog. With 5 years of experience as a wordsmith in SaaS, I know how to make texts resonate with readers’ queries✍🏼
Back to Blog
Focus on your business
goals while we take care of your data!
Try Coupler.io