We are generating SQL Server reports and rendering them to Excel format. Each report creates a new Workbook. We need to be able to open workbook1 and workbook2 and then copy a sheet1 from workbook2 into workbook1 as the last sheet.
We can do this using the Excel object model, but would prefer to use the Infragistics.Excel so that Office does not have to be installed on a server.
I have looked over the Infragistics.Excel documentation and do not see any API support for this.
Any help would be appreciated.
Kent
The feature has not yet been implemented. Can you send the code (or a portion of it) which reproduces the error and I will try to find out what's going on? Also, which version are you using?
Mike we are doing an excel evaluation for ingragistics. but we have copy over functionality exsting in current system from one workbook to another. we used the code you have mentioned above, but we are recieving the same error. has this feature been implemented yet ?
Thanks.
Srikanth
How are you copying the format? You should do something like this: destCell.CellFormat.SetFormatting(sourceCell.CellFormat)
When I try to move the cell format from one workbook to another, I get the following error:
"The specified format does not belong to the same workbook as this format.\r\nParameter name: source".
Can you please help.
No, this feature is currently not implemented. You can submit a feature request for this and that will increase the likelihood that it will get implemented.
As for manually copying over data, I suggest using and foreach statement to iterate through the Worksheet.Rows collection. This will only return the rows which have been accessed, which means they probably have cell data and/or formatting. For each row iterated, copy over the row's height and formatting and then iterate the row's Cells collection, again using a foreach statement, because that will only return the cells with data and/or formatting. For each cell iterated, copy over the cell's formula if present. Otherwise, copy over the value. Then copy over the cell's CellFormat using the SetFormatting method listed above. After iterating the Rows collection, also iterate the Worksheet.Columns collection (again using a foreach statement). Copy over the formatting and width of each column.