How to have multiple sheets in Excel ActiveReports 7? - c#

I can generate one sheet, but I can't find a way to generate multiple sheets in one Excel file.
I tried to use GrapeCity.SpreadBuilder.Workbook but I haven't found a way to make it work.
Thanks in advance.

Thank you for using ActiveReports The excel export in ActiveReports is used to export the report as it appears. in the latest version of ActiveReports we have an Excel transformation device that allows you to break the report over multiple excel sheets.
the following sample of code creates workbook with 2 sheets via SpeadBuilder API:
GrapeCity.SpreadBuilder.Workbook sb = new GrapeCity.SpreadBuilder.Workbook();
sb.Sheets.AddNew();
sb.Sheets[0].Cell(1, 1).SetValue("Sheet #1");
sb.Sheets.AddNew();
sb.Sheets[1].Cell(1, 1).SetValue("Sheet #2");

Related

Generate many SSRS reports each one on a different sheet in one excel file (in c#)

I'm working on a SSIS and SSRS project
I need a c# code to generate an excel file that contains many sheets ( each one of them contains the report SSRS )
I used this tutorial and it worked but it gives me different excel files for each report
https://www.sqlservercentral.com/articles/generate-ssrs-reports-from-a-ssis-package
Thanks in advance.

create a report from template using C# excel OpenXML API

I've been using Microsoft COM model to prepare reports but it is slow and fails if server does not have excel installed. So I am moving to using OpenXML for creating reports from a server process that does a ton of other things as well.
I've a template that contains named ranges for data that I need to change or extend, named charts, named chart series, named worksheets, etc. All my formatting is contained in excel file and all I do in my server side process is populate the file with data.
These are the steps that I need to replicate using Excel OpenXML:
Open an existing sheet and create a new sheet based on it.
Get the worksheet by worksheet name
Get the Named Ranges in that worksheet.
Populate the Named Ranges from data and extend the ranges if required based on data set.
Get Chart by Chart Name
Get Chart Series by Series Title
Set Chart series to the new range
Export Chart to jpeg to be used in html.
Save new File.
Is it possible to do these steps in OpenXML cleanly? Any examples will help me a lot. Or a light weight library that does this. Some of these 3rd party libraries are too big and are more useful in creating new sheets from scratch.
Any help appreciated.
AFAIK, with OpenXml you can do anything.
I recommend a ClosedXml lib, it wraps OpenXML SDK and makes it easier to do your job. Link contains samples and stuff. Hope that helps.

Unable to print spreadsheet by using ExcelLibrary

i am using this Create Excel (.XLS and .XLSX) file from C#
What steps will reproduce the problem?
1. Create a spreadsheet using excellibrary
2. Open the spreadsheet in Excel
3. Try to print the spreadsheet
What is the expected output? What do you see instead?
Should print, instead get message 'Excel could not find anything to print'
If you copy the data to a new spreadsheet then it prints fine.
is there any solution?
after some searching i have found this link
http://code.google.com/p/excellibrary/issues/detail?id=31&colspec=ID%20Type%20Status%20Priority%20ReportedBy%20Owner%20Summary%20Opened
by this i have solve this
Here is the recompiled dll with the print fix.
https://excellibrary.googlecode.com/issues/attachment?aid=310010000&name=ExcelLibrary.dll&token=ABZ6GAfhAt8vF9GuExA0wgjRJnejNwrlVg%3A1412108599039

Generating Excel file with some number of sheets with a single template

i am generating an excel file with some number of sheets. I am using a template .xlt file which have one worksheet. Now I am able to generate the xl file with that template if there is only one worksheet in that excel file. But when I have to create more than one worksheet, I am unable to do that. Then the excel file do not use the template and instead use a blank worksheet. Can anyone point me to some reference where i can use the same template worksheet to create n number of worksheets in the same workbook.
SpreadsheetGear for .NET can do it.
See the "Worksheet with Chart to Multiple Worksheets with Charts" sample on our Excel Reporting Samples page for an example or download the free trial here to try it yourself.
Since the SpreadsheetGear API is very similar to the Excel API, you should be able to adapt the SpreadsheetGear code to work with Excel if you need to.
Disclaimer: I own SpreadsheetGear LLC

Using templates in excel with C#

As part of the c# program that I am producing I need to generate 1 workbook containing; 2 different worksheets and a 3rd that could be produced any number of times, what is the most effective way of doing this? I have looked into using templates although I am unsure how to repeat certain worksheets whilst only displaying others once. Any help or advice would be appreciated.
A simple way is to make a hands off template example workbook with the three worksheets. Then make a copy of it. Open both and re-copy worksheet number 3 on to the working workbook as a new worksheet as needed.
In response to the comment:
There are a couple of excel engines in a .net component products our there like spreadsheet gear or aspose cells. But if your application is a windows form based and where the application is guaranteed to run has office you can use office automation. You can't legally use office automation on a web server, but it is just as possible on a web server as on a client desktop. I've used the aspose cells and it's very easy to work with and very capable and a little less expensive than spreadsheet gear, but spreadsheet gear does also have a good reputation. Both of those components have very good documentation on how to do anything with excel. But if you have excel and want to use office automation, be sure to look for example code on the web on how to properly close excel from c# or vb.net. There are some tricks to getting it to close properly.
SpreadsheetGear for .NET has ISheet.CopyAfter / CopyBefore methods which enable you to copy an entire worksheet within a workbook or between workbooks.
You can see an example of duplicating a single worksheet multiple times in the Worksheet with Chart to Multiple Worksheets with Charts sample on the SpreadsheetGear / Excel Reporting Samples page here.
Disclaimer: I own SpreadsheetGear LLC
I have done this before with templates. I would create a template xls with the first two worksheets that you don’t want changed, then add a 3rd worksheet that you could copy to the end of the workbook (as you need more worksheets).
If you know ahead of time how many of the 3rd worksheet you need, then you can copy them to the end and delete the template 3rd slot.
ExcelTemplateManager t = new ExcelTemplateManager(template_path, log_path);
t.CopyWorksheetToEnd(3);
t.CopyWorksheetToEnd(3);
t.RemoveAtIndexWorksheet(3);
t.SetSomeValue(3);
t.SetSomeValue(4);
t.Close();
If you don’t know, then keep the template around to copy it to the end as needed, then when you are done, just remove the 3rd worksheet template.
ExcelTemplateManager t = new ExcelTemplateManager(template_path, log_path);
t.CopyWorksheetToEnd(3);
t.SetSomeValue(4);
t.CopyWorksheetToEnd(3);
t.SetSomeValue(5);
t.RemoveAtIndexWorksheet(3);
t.Close();
I used the Microsoft.Office.Interop.Excel dll to create my ExcelTemplateManger class. The basic idea is to create a copy of the template excel file, and work off the copy. Let me know if you need help setting that part up, but it should be too bad.

Categories

Resources