I'm working on a VS 2008 asp.net webforms application in which it contains an existing RDLC (Client file, and NOT the RDL Server side file).
The problem is upon exporting to excel, all of the worksheets are not named properly, i.e. Sheet1, Sheet2, etc. I have found many examples on exporting data, on SQL Server 2008 R2 feature of RDL, however I am in need of a RDLC solution?
Does anyone know about how to either "fix" this or do some sort of post processing to rename the tabs so the customer doesn't end up seeing Sheet1, Sheet2, Sheet3,etc.?
- Application is choosing the path of the RDLC file
- Adds DataSource
- Chooses xls
- Does all the Responses
I see this Stackoverflow link How to get named excel sheets while exporting from SSRS, however:
- Can't do the Macro
- Can't do the export as SSML
- I am NOT using RDL / SQL Server 2008 R2 SSRS, thus the other answers are misleading for people using the RDLC
Sheet renaming isn't supported with the version of RDLC report. I'm guessing you can't upgrade. So here's a work around: Save the report to a file as normal. Then open it again using Microsoft.Office.Interop.Excel or any other Excel library to rename the sheets. Once you do this save and you're done.
using Excel = Microsoft.Office.Interop.Excel;
Excel.ApplicationClass xl=new Excel.ApplicationClass();
Excel.Workbook xlBook;
Excel.Worksheet xlSheet;
string filePath = Server.MapPath(@"\report.xls");
xlBook = (Workbook)xl.Workbooks.Open(filePath,Type.Missing,
Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing
,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
xlSheet = (Worksheet)xlBook.Worksheets.get_Item(1);
xlSheet.Name = "New Sheet Name";
xlBook.Save();
xl.Application.Workbooks.Close();
List of different libraries that you can use if this one doesn't work for you: Free Libraries
1. Close XML Library - http://closedxml.codeplex.com/documentation
2. Open XML SDK - http://msdn.microsoft.com/en-us/library/bb448854.aspx
3. NOPI - http://npoi.codeplex.com/
4. CarlosAG - http://www.carlosag.net/Tools/ExcelXmlWriter/
Paid Libraries
5. Spreadsheet Gear
6. Smart XLS
7. Office Writer
8. Spire
I would upgrade to the RDL 2010 schema - it supports Excel Named Sheets (amongst other useful enhancements):
http://msdn.microsoft.com/en-us/library/ee960138.aspx
Your not going to be able to do it.
http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/54caf25b-b17b-474c-aa47-fc884f90af03
http://go4answers.webhost4life.com/Example/reportviewer-eport-excel-naming-sheets-157612.aspx
http://forums.asp.net/post/4140154.aspx
This may help for post processing using excels xml dialect:
http://spacefold.com/lisa/post/Changing-the-Sheet-names-in-SQL-Server-RS-Excel-QnD-XSLT.aspx