Hello,
Our application is using Aspose.Cells for converting data from XML Spreadsheet format to XLSX format but when testing the latest version of Aspose.Cells we discovered that it is no longer possible to read files containing columns with AutoFitWidth set.
The following exception is raised:
System.ArgumentException occurred
HResult=-2147024809
Message=Invalid column index.
Source=Aspose.Cells
StackTrace:
at . . (Int32 )
InnerException:
During testing I found that the error was introduced between versions 7.3.2.0 and 7.3.4.0. See attached file for example on a file that can no longer be read.
thanks,
Johnny Andersen.
Hi,
Thanks for your posting and using Aspose.Cells.
Please download and try the latest version Aspose.Cells
for .NET v7.4.0.5 and see if it resolves your issue.
If your problem still occurs, then please provide us your simple sample runnable project and source files replicating this issue with the latest version.
We will look into your issue and help you asap
Hello,
I tried to use the fixed version you provided but it did not solve the issue.
To reproduce the issue I have compiled a simple simple console application with the code at the end of this post. Run the executable by using the file attached in the first post of this issue as command line parameter.
The program will raise the same exception as before when running version 7.2.4 and upwards, but works fine with older versions of Aspose.Cells.
thanks, Johnny Andersen
namespace AsposeCellsConvert { using System.Diagnostics; using System.IO;<span style="color: blue;">using</span> Aspose.Cells; <span style="color: blue;">class</span> <span style="color: rgb(43, 145, 175);">Program</span> { <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args) { <span style="color: blue;">if</span> (args.Length < 1) { <span style="color: rgb(43, 145, 175);">Trace</span>.WriteLine(<span style="color: rgb(163, 21, 21);">"Invalid number of arguments: Expecting AsposeCellsConvert.exe <source>"</span>); <span style="color: blue;">return</span>; } <span style="color: blue;">string</span> l_sourceFile = args[0]; <span style="color: blue;">if</span> (!<span style="color: rgb(43, 145, 175);">File</span>.Exists(l_sourceFile)) { <span style="color: rgb(43, 145, 175);">Trace</span>.WriteLine(<span style="color: rgb(163, 21, 21);">"Specified source file does not exist: "</span> + l_sourceFile); <span style="color: blue;">return</span>; } <span style="color: blue;">string</span> l_targetFile = l_sourceFile + <span style="color: rgb(163, 21, 21);">".xlsx"</span>; Aspose.Cells.<span style="color: rgb(43, 145, 175);">Workbook</span> l_workbook = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Workbook</span>(l_sourceFile); l_workbook.Save(l_targetFile, <span style="color: rgb(43, 145, 175);">FileFormatType</span>.Xlsx); } }
}
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
We were able to replicate this issue using the latest version with the following code.
We have logged this issue in our database. We will look into this issue and fix it. Once the issue is fixed or we have some other update for you, we will let you know asap.
This issue has been logged as CELLSNET-41433.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\AutoFitWidth+Error.xml”;
Aspose.Cells.Workbook l_workbook = new Workbook(filePath);
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
We have fixed the issues.
Please download and try this fix: Aspose.Cells for .NET v7.4.1.1 and let us know your feedback.
Hello,
our project is targeting the .NET Client Profile, so I would require a version of Aspose.Cells.dll for this. Could you send me a link to the correct version?
thanks,
Johnny Andersen
Hi,
Hello,
would it be possible to get a fix out for me faster? My application is in the late release stage and is scheduled for release to customers monday..
thanks, Johnny Andersen
Hi,
Hi,
Hello,
I have installed and tested the fix. Aspose.Cells does not crash anymore when AutoFitWidth is set, but the columns are not actually sized when the file is opened in Excel. So the proposed solution still does not restore functionality as it was in version 7.3.2.0.
thanks,
Johnny Andersen
Hi,
Hello,
I have tested the fix withy the simple code written earlier in this issue (https://forum.aspose.com/t/97638)
The testdata is also the same, but I attach a file that illustrates the problem further. In Cell A1 there is a text that is a bit longer than the other cells - Column A is not expanded to fit this text (See attached output file for result).
thanks,
Johnny Andersen
Hi,
Hello,
the reason why I reported this issue is that our application is converting data from XML Spreadsheet format to Excel format (xlsx) without knowing the structure of the file. We do not know whether a column is supposed to be fixed or autofit at the time of the conversion.
I understand that I can call AutoFitWidth for a column in a spreadsheet but as I do not know which columns should be autofit we have relied on Aspose.Cells to retain the setting in the XML Spreadsheet file when writing the XLSX Format.
This worked perfectly fine until it was changed from version 7.3.2.0 to 7.3.4.0. If you could please run the test case with Aspose 7.3.2.0 you would notice that the first column in the resulting file would adjust its width to the contents when opened in Excel. In newer versions of Aspose.Cells (that is from 7.3.4.0 onwards) The AutoFit information seems to be lost when writing XLSX.
We would very much like to get this functionality back as the AutoFit functionality is an importent feature when formatting documents to our end-users.
thanks,
johnny Andersen
Hi,
Here is the simplest code that I used with v7.3.2.
Sample code:
Workbook wbk = new Workbook(“e:\test2\AutoFitWidth+Error.xml”);
wbk.Save(“e:\test2\out1_AutoFitWidth+Error.xlsx”, SaveFormat.Xlsx);
Hello,
and thanks for checking out the issue further. Please get in touch again if you need more information.
Johnny Andersen
Hi,
Hello,
could you also post a version for :NET 4 Client Profile?
thanks,
Johnny Andersen
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
We will provide you a client profile version tomorrow or as soon as possible.