views:

1499

answers:

1

Hi,

Is there a way to convince Crystal Reports to export a page / group / whatever to separate worksheets when exporting to Excel (Data Only)? I'm using the CR that came with VS2008 (version 10.5)

Thanks.

A: 

According to the documentation you cannot export a report directly to multiple worksheets in a single Excel workbook.

When the limit of 65536 rows in Excel is reached though, the exporter does create a new worksheet, but you are not in control :)

update
To create your own Excel merger:

PRE: Make sure you have the Office (Excel) SDK libraries installed.
PRE: Place the files that need to be merged in a single directory.

In a VS2008 solution:

  • Create a new empty Excel Workbook (variable: objNewWorkbook)
  • Loop through the files in the directory (where you placed the Excel files) and for each item:
    1. Load the file as a Excel Workbook (variable: objWorkbookLoop)
    2. Create a new Worksheet in objNewWorkbook (optionally: with the filename of objWorkbookLoop) (variable: objNewWorksheetLoop)
    3. Copy the data from (probably sheet1 in) objWorkbookLoop to objNewWorksheetLoop
  • Finally save objNewWorkbook to a file.
Ropstah
This is some kind of workaround (just to get you going): http://www.zdnetasia.com/insight/software/0,39044822,39212144,00.htm
Ropstah
Unfortunately I can't have Excel automation on the server, otherwise it could probably work. Something that could take N Excel files and merge them into a single Excel file with each previous file as a separate worksheet would work, but I couldn't find something that would do that at a reasonable price.
pbz
If it's a one-time operation and it's too much work to do by hand, you could check my updated answer to write your own merger.. Shouldn't be to hard as you don't need error checking etc if you're only using it yourself. (unless you're stupid and start entering wrong values hehe)
Ropstah