We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error while combining workbooks (Critical)

I have some 20+ workbooks with only one sheet (each 17 M size) . I am tyring to combine the worksheet in these 20+ worbooks into one workbook as separare sheets. The first 3 or 4 worksheets worked fine, after that the system started slowing down, started consuming more and more memory and finally ended with Out of memory Exception. I have 2G RAM on my machine.

Here is my sample code

public void Merge(string[] files)
this.book.Worksheets[0].Name = "Page 1";

for (int i = 1; i < files.Length; i++)
if (files[i] != this.fileName)
LoadDataOption ldo = new LoadDataOption();
ldo.SheetIndexes = new int[] { 0 };

LoadOptions lo = new LoadOptions(LoadFormat.Excel97To2003);
lo.LoadDataOptions = ldo;

Workbook mergeBook = new Workbook(files[i], lo);

mergeBook.Worksheets[0].Name = string.Format("Page {0}", i);


this.book = null;

Thank you.


Hi Tomy,

Thank you for considering Aspose.
We are looking in to this issue. It is helpfull if you please forward us your sample application & file having size 17MB. This will help us finding the issue.


Hi Tomy,

Update version of Aspose.Cells.dll is attached. Please use this version.
Code below is the work around. It is a temporary solution; we are in process of fixing this issue.

Code snippet:

string[] files = new string[2];
files[0] = @"F:\FileTemp\6249.xls";
files[1] = @"F:\FileTemp\A0071 - Class I Operations - TO005 CDRL - Afghanistan - 20100803.xls";
string cacheFile = @"F:\FileTemp\temp.txt";
string dest = @"F:\FileTemp\dest.xls";


Thank you for the quick respose. It worked for most part. It successfully combined the sheets.

But on the destination worksheet, some of the formatting is incorrect. For example, The column width and row height on the destination sheet is different from what is in the source sheet. Also the image on the source sheet is missing from the target sheet.

Other than these two issues, everything look great.

Thank you.


Would it also be possible to set the sheet names with user specified names rather than Sheet1, Sheet2 etc.

I am trying load the entitre sheet after merging and updating sheetnames, it is throwing a memory exception when saving the sheet.

Is it possible to pass the sheet name array to the methods as well.

Thank you,



Well, I am afraid renaming sheets while merging is not possible but you may do it using Worksheet.Name attribute later. I have tested with the following sample codes with my custom excel files and it works fine.

Sample code:
string[] files = new string[2];
files[0] = @“e:\test\Book1.xls”;
files[1] = @“e:\test\Book2.xls”;
string cacheFile = @“e:\test\temp.txt”;
string dest = @“e:\test\dest.xls”;
CellsHelper.MergeFiles(files, cacheFile, dest);
Workbook workbook = new Workbook(“e:\test\dest.xls”);
int i = 1;
foreach (Worksheet sheet in workbook.Worksheets)

sheet.Name = “My_Custom_Sheet_” + i.ToString();



If you find the issue, kindly do post your template files here, we will check it soon.

Thank you.

Thanks for the response. The new solution seems like work fine.

But some of my sheets have images on them. Looks like the merge is not moving the images to the target sheet.

Can you please look into it.

Thank you

Hi Tomy,

<!–[if gte mso 9]>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}


We only support to combine the data and styles in CellsHelper.MergeFiles method. We may look into it. If we have some update, we will let you know about it.

Thank you.