TAB Delimited Export in SSRS

By | October 28, 2014

Ever wondered how do you export TAB delimited reports in SSRS? It’s quite easy as you can configure SSRS to export it using the CSV render inside the ReportingServices rendering engine of SQL server.  You can do that by updating the rsreportserver.config file which can be found in the following path C:\Program Files\Microsoft SQL Server\MSRS{YourSQLServerVersion}.MSSQLSERVER\Reporting Services\ReportServer.

02 Report Server Configuration

All you need to do is add another item on the <Render> section of the configuration file.

So by default it would look like this.

03 Render Section

then you can add a new extension anywhere you want inside the <Render> section, like in this example where we placed it just below the CSV extension.

04 New Render Section

You can customize to whatever you want like the one I did below.

<Extension Name="TAB" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering">
     <Name Language="en-US">TAB Delimited</Name>

To give you an idea what each of this means here are some short descriptions to give it some clarity

  • Extension Name – The name of extension used throughout SSRS, it can also be used if you render you reports programatically which I will explain below.
  • OverrideNames Name – The name that will show on the dropdown list of SSRS report pages, you can name it to what ever you want.
  • FileExtension – The file extension of the export (i.e. TXT, CSV)
  • NoHeader – Indicates whether the Header (column names) are excluded from the output, you can set it to either True or False
  • FieldDelimiter – The delimiter string to use in the result, you can use comma(,), semicolon(;), pipe(|), tab (&#9;), etc
  • Qualifier – The qualifier string to enclose each field result, this will only show if data contains same the same qualifier string to escape the character, it will also show once results contain the field delimiter or record delimiter characters.

Now once you set that up correctly the menu will now show and you can export the file as defined on your configuration.

01 Tab Delimited

Lets now go to programmatic usage, usually you will use ReportExecutionService to render your report from a code.  Now that you set up the “TAB” extension you can use that as the format of your report like such

//Get Report Server
var reportExecutionService = new ReportExecutionService();
reportExecutionService.Credentials = System.Net.CredentialCache.DefaultCredentials;
reportExecutionService.Url = "http://{YourServerName}/reportserver/reportexecution2005.asmx";
var reportPath = "/YourReportSubFolder/";
reportExecutionService.Timeout = 180;
reportExecutionService.LoadReport(reportPath + "YourReportName"null);
//Set Rendering Parameters
var format = "TAB";
string encoding;
string mimeType;
string extension;
Warning[] warnings = null;
string[] streamIDs = null;
byte[] result = reportExecutionService.Render(format, nullout extension, out mimeType, out encoding, out warnings, out streamIDs);
//Create File
var exportedFile = File.Create(@"C:\ExportLocation\FileName.txt", result.Length);
exportedFile.Write(result, 0, result.Length);

Easy isn’t it