Hi,
After copiing a column from one worksheet to another worksheet in another workbook using Range.Copy Excel crashes after opening the file.
I am using version 9.0.0. .Net 4.0. Win 7 64bit.
I am using following code to reproduce the problem:
Save fileSrc to fileTgtWorking, to be sure the problem occurs not with saving the worksheet again.
Create a range with column “N” from sheet “Testsheet” from fileCopyBase and copy it column “D”.
Save it to fileTgtNotWorking -> Excel crashes after opening it.
private static void Test_ExcelCrash()
{
string fileSrc = @“C:\temp\Test_ExcelCrash_Src.xlsm”;
string fileCopyBase = @“C:\temp\Test_ExcelCrash_CopyBase.xlsm”;
string fileTgtWorking = @“C:\temp\Test_ExcelCrash_Tgt_Working.xlsm”;
string fileTgtNotWorking = @“C:\temp\Test_ExcelCrash_Tgt_NotWorking.xlsm”;
<span style="color:#2b91af;">Workbook</span> wbSrc = <span style="color:blue;">new</span> <span style="color:#2b91af;">Workbook</span>(fileSrc);
<span style="color:#2b91af;">Workbook</span> wbCopyBase = <span style="color:blue;">new</span> <span style="color:#2b91af;">Workbook</span>(fileCopyBase);
wbSrc.Save(fileTgtWorking); <span style="color:green;">//<- Working</span>
<span style="color:#2b91af;">Worksheet</span> testSheetSrc = wbSrc.Worksheets[<span style="color:#a31515;">"TestSheet"</span>];
<span style="color:#2b91af;">Worksheet</span> testSheetCopyBase = wbCopyBase.Worksheets[<span style="color:#a31515;">"TestSheet"</span>];
<span style="color:#2b91af;">Range</span> sourceRange = testSheetCopyBase.Cells.CreateRange(13, 1, <span style="color:blue;">true</span>);
<span style="color:#2b91af;">Range</span> tgtRange = testSheetSrc.Cells.CreateRange(3, 1, <span style="color:blue;">true</span>);
<span style="color:#2b91af;">PasteOptions</span> options = <span style="color:blue;">new</span> <span style="color:#2b91af;">PasteOptions</span>();
options.PasteType = <span style="color:#2b91af;">PasteType</span>.All;
tgtRange.Copy(sourceRange, options);
wbSrc.Save(fileTgtNotWorking); <span style="color:green;">//<- Not working</span>
}</pre>Attached are all files needed and created.<br><br>Let me know if you need more information.<br>
Hi,
Thanks for your posting and using Aspose.Cells.
We have tested this issue with your sample code and source excel files using the latest version:
Aspose.Cells for .NET v9.0.1.0 and found this issue. Excel crashes after coping a column to another worksheet.
We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.
This issue has been logged as
- CELLSNET-44755 - Excel crashes after coping a column to another worksheet
I have also attached the
output excel file generated with this code at my end for a reference.
C#
string fileSrc = @“D:\Downloads\Test_ExcelCrash_Src.xlsm”;
string fileCopyBase = @“D:\Downloads\Test_ExcelCrash_CopyBase.xlsm”;
string fileTgtWorking = @“D:\Downloads\Test_ExcelCrash_Tgt_Working-sha.xlsm”;
string fileTgtNotWorking = @“D:\Downloads\Test_ExcelCrash_Tgt_NotWorking-shanot.xlsm”;
Workbook wbSrc = new Workbook(fileSrc);
Workbook wbCopyBase = new Workbook(fileCopyBase);
wbSrc.Save(fileTgtWorking); //<- Working
Worksheet testSheetSrc = wbSrc.Worksheets[“TestSheet”];
Worksheet testSheetCopyBase = wbCopyBase.Worksheets[“TestSheet”];
Range sourceRange = testSheetCopyBase.Cells.CreateRange(13, 1, true);
Range tgtRange = testSheetSrc.Cells.CreateRange(3, 1, true);
PasteOptions options = new PasteOptions();
options.PasteType = PasteType.All;
tgtRange.Copy(sourceRange, options);
wbSrc.Save(fileTgtNotWorking);
Hi again,
This is to update you that the ticket logged earlier as CELLSNET-44755 has been marked resolved. We will shortly share the fix here after ensuring the quality and incorporating other enhancements.
Hi,
Thanks for using Aspose.Cells.
Hi,
thanks for the fix, it works for the example i provided.
But running it with my full program, excel needs to repair the file.
Attached you will find the generated file and the file excel repaired.
The file “Testsheet_WrongFormula.xlsm” is generated via Aspose Cells.
“Testsheet_WrongFormula_Repaired.xlsm” is already repaired by Excel.
Hope this is enough information for you to find the problem.
The repaired worksheet is ~50KB smaller. If it is possible for you, I would like you to have a look at it, but it is no problem at all.
Hi,
Using following code, I found out 3 cells may be the problem:
private static void Test_CompareWorkbooks()
{
string srcFilePath = @“C:\temp\Testsheet_WrongFormula.xlsm”;
string tgtFilePath = @“C:\temp\Testsheet_WrongFormula_Repaired.xlsm”;
<span style="color:#2b91af;">Workbook</span> wbSource = <span style="color:blue;">new</span> <span style="color:#2b91af;">Workbook</span>(srcFilePath);
<span style="color:#2b91af;">Workbook</span> wbTarget = <span style="color:blue;">new</span> <span style="color:#2b91af;">Workbook</span>(tgtFilePath);
<span style="color:blue;">foreach</span> (<span style="color:#2b91af;">Worksheet</span> sheet <span style="color:blue;">in</span> wbSource.Worksheets)
{
<span style="color:#2b91af;">Worksheet</span> tgtSheet = wbTarget.Worksheets[sheet.Name];
<span style="color:blue;">foreach</span> (<span style="color:#2b91af;">Cell</span> cell <span style="color:blue;">in</span> sheet.Cells)
{
<span style="color:#2b91af;">Cell</span> tgtCell = tgtSheet.Cells[cell.Row, cell.Column];
<span style="color:blue;">if</span> (cell.IsFormula)
{
<span style="color:blue;">if</span> (cell.Formula != tgtCell.Formula)
{
<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"Formula: {2}: Row:{0} - Col:{1}."</span>, cell.Row, cell.Column, sheet.Name));
}
}
<span style="color:blue;">else</span>
{
<span style="color:blue;">if</span> (cell.StringValue != tgtCell.StringValue)
{
<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"Value: {2}: Row:{0} - Col:{1}."</span>, cell.Row, cell.Column, sheet.Name));
}
}
}
}
}<br><br><b>Output:<br></b><br>Formula: Plasticizing1: Row:106 - Col:11.<br>Formula: Plasticizing1: Row:108 - Col:11.<br>Formula: Plasticizing1: Row:115 - Col:11.<br><br>Those cells only have a value, but no formula:<br><br><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAuYAAAAtCAIAAABtSzlaAAAO+0lEQVR4nO1dPY7juBLWUfYOznSQDTqbRMFeoq8gTNaZHzZsbKrImIUu0OkGGjTQwGQDGB12Vi+QRBXrj5Qt2ZZdHwoNNy1R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lDM8moDnFiMonUxbNiTmmIFjP5raJ+sp5idZ/cCWeZXE41sUqTwz1229nkpUecxaGhkP4E0NNRZ933hRlwXMfzWCzkD/ENpSBn+ZTsjAkJm+a+M4b6M238HSPcYoSgJet80TKojzxUZf6g9ZxQ7CGwS/CYk28DwOvqgg9j6lNnw7TPassiup7WVBbiFMg5CTsJtgpK7MvGQtDGtayuWSl8BKBsM7FS/yJIYfj2ljxvSynvZFl2GEbds1G22/ZARAvA0X5l40uDEE03/E1i366nDLkZJ9jQQlBlEgHdmKcP6fJ/Pjb6H7XXMQR1TuzTtE+USF+x0kzbfAs2Hs1yC7m5L4K4I+8hqoqdsePmo+fsqYNDGozplWxAyzPxkseIsftm2w7BXqKYDQhY5XN6kvks739dlWbi1cMO4LjzJNYou7HcsricKyLjbz9Nv9x5g0i/V6WNE44ZbtYMx6orwC5ICIdHsCzt2DzBeCUxeFYHdugLHyl556Q9fbbBB4gsE1o4nvfZWu+dqShD1XdvWdvwObnw99+63BcBLdMWejqzr1iid8YuvvA9gjo1x34Kph71uFwOABum7I8CvxnER0Oh8PhSMKiLJ8Oh8PhcDgctwHPsjgcDofD4dgAnLI4HA6Hw+HYAJyyOBwOh8Ph2ACcsjgcDofD4dgAnLI4HA6Hw+HYAJyyOBwOh8Ph2ACcsjgcDofD4dgA/g+WZo0GY4oISwAAAABJRU5ErkJggg==" alt=""><br></pre><br>Hope this helps you.<br>
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
I tried to execute your sample code and found that your code uses the source excel file named
Testsheet_WrongFormula.xlsm provided by you in your
above post but this file does not open in Microsoft Excel and Microsoft Excel gets crashed. You mentioned that this file was generated using Aspose.Cells, so please provide us the code (preferably console application project) that generates your source excel file Testsheet_WrongFormula.xlsm.
The code you provided will not work because the source excel file Testsheet_WrongFormula.xlsm itself is corrupt and you cannot get correct results from corrupt source excel file. Thanks for your understanding and cooperation in this regard. Have a good day.
Hi,
I found out, the problem with Range.Copy is gone now, but still persists with CopyColumn.
private static void Test_ExcelCrash_CopyColumn()
{
string fileSrc = @“C:\temp\Test_ExcelCrash_Src.xlsm”;
string fileCopyBase = @“C:\temp\Test_ExcelCrash_CopyBase.xlsm”;
string fileTgtWorking = @“C:\temp\Test_ExcelCrash_Tgt_CopyCol_Working.xlsm”;
string fileTgtNotWorking = @“C:\temp\Test_ExcelCrash_Tgt_CopyCol_NotWorking.xlsm”;
<span style="color:#2b91af;">Workbook</span> wbSrc = <span style="color:blue;">new</span> <span style="color:#2b91af;">Workbook</span>(fileSrc);
<span style="color:#2b91af;">Workbook</span> wbCopyBase = <span style="color:blue;">new</span> <span style="color:#2b91af;">Workbook</span>(fileCopyBase);
wbSrc.Save(fileTgtWorking); <span style="color:green;">//<- Working</span>
<span style="color:#2b91af;">Worksheet</span> testSheetTgt = wbSrc.Worksheets[<span style="color:#a31515;">"TestSheet"</span>];
<span style="color:#2b91af;">Worksheet</span> testSheetCopyBase = wbCopyBase.Worksheets[<span style="color:#a31515;">"TestSheet"</span>];
testSheetTgt.Cells.CopyColumn(testSheetCopyBase.Cells, 13, 11);
wbSrc.Save(fileTgtNotWorking); <span style="color:green;">//<- Not working</span>
}<br><br>Hope this is enough information for you.<br></pre><br>
Hi,
Thanks for providing us sample code, sample files and details.
Yes, you are right, I found that it works fine with copying ranges but still it does not work when copying a column. The final output file crashes MS Excel when opening the file into it. I have reopened your issue “CELLSNET-44755”. We will look into it to figure it out soon.
Thank you.
Hi,
Thanks for using Aspose.Cells.
This is to inform you that we have fixed your issue CELLSNET-44755 now. We will soon provide the fix after performing QA and including other enhancements and fixes.
Hi,
Thanks for using Aspose.Cells.
Hi,
I tested .Net4.0 version and it works fine, thanks.
Hi,
Thanks for your feedback.
Good to know that your issue is sorted out by the new fix/version. Feel free to contact us if you have further comments or questions, we will be happy to assist you soon.
Thank you.
The issues you have found earlier (filed as CELLSNET-44755) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.