Exception "Instance is Read-only."

Hello Team,

Error - crash with Exception “Instance is Read-only.”

  1. When we open xls files (for example, the file sl_os375708.xls), if it contains a cell format “ММММ” (Cyrillic) (full name of a month), for example, “ДД ММММ ГГГГ ч:мм” the application is crushed
    Code :
    Excel.Workbook doc;
    var lo = new LoadOptions ();
    lo.Region = CountryCode.Russia;
    doc = new Excel. Workbook (input, lo);
    where input is the path to the file (sl_os375708.xls in archive)

  2. When we open xlsx files (for example, the ConverterExcelTest1.xlsx in archive), if it contains a cell format “МММ” (Cyrillic!) (abbreviated name of a month), for example “ДД МММ” the application is crushed
    Code :
    Excel.Workbook doc;
    doc = new Excel.Workbook (input);

Here the situation is a bit more complicated.

  • If we add LoadOptions and specify the region (lo.Region = CountryCode.Russia), then the constructor passes, but the export to pdf goes wrong (see the file ConverterExcelTest1.xlsx.pdf in archive). In the source xlsx file in the cell with the format it is displayed “29 май”, and in the result pdf file it is displayed as “29 мая”.
  • On some files (example - book2.xlsx in archive) with this format, the error does not occur when the file is loaded, but it occurs when we try to save it to pdf. If you try to save such a file in xps, result builds without errors, but there are no pages with a problematic format in the resulting xps file

With best regards,
Oleg Istomin

Aspose.zip (52.4 KB)

Aspose2.zip (1.9 MB)

@eospv,

Thanks for your query.

I have tried to reproduce these issues but none of them is observed. Please share a complete solution (runnable project) along with any system settings which are required to observe these errors. We will reproduce the scenario here and provide our feedback accordingly.

Hi!
I created a solution in which we can observe the problem
See attachment:
AsposeTest.zip (4.9 MB)

Also here is a screenshot of this application output when it runs on our local hardware.
image.png (23.6 KB)

Please note the Stack Trace of an exception

Versions:
Aspose.Cells : 19.2
.Net Framework : .Net Framework 4
Windows : Windows 10 Enterprise
Version : 1511
Build : 10586.1540

Here are screenshots of the date and time local settings:
image.png (23.8 KB)

@eospv,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46618 - Instance is Read-only exception

For the formatted result “29 май” and “29 мая”, if you can give us some knowledge about the rule that Russian language determines format of the month name to “май” or “мая”, then we can solve it in a better way. And if the difference is caused by different CultureInfo object, then using the correct and newly instantiated CultureInfo object with the LoadOptions in your code can also solve both the issues.

About “май” and “мая”.
This is called Grammatical case. “май” is a nominative case and “мая” is a genitive case. Unfortunately, I am not a linguist and my English is also VERY far from perfect, so my ability to explain what it is is limited.
I will try to explain it as a software developer.
In C# there are two fields in System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat:
AbbreviatedMonthNames and AbbreviatedMonthGenitiveNames
In AbbreviatedMonthNames - “май”, in AbbreviatedMontGenitiveNames - “мая”
See screenshot:
image.png (9.5 KB)

But in you case field AbbreviatedMonthNames contains “мая”.
Moreover, if I set in LoadOption CultureInfo value “май” in the required month, then it will be changed to “мая” when loading the Worksheet
See screenshot:
image.png (40.1 KB)

Note that the value “мая” is highlighted in red as a sign that it was changed during the last operation (creating the Worksheet object)
It seems to me that you just do not quite correctly fill in the AbbreviatedMonthNames field and instead of “май” enter there the same value as in the AbbreviatedMonthGenitiveNames field (“мая”).
I also tried to change CultureInfo object of Worksheet object after loading as following
workbook.Settings.CultureInfo = System.Globalization.CultureInfo.CurrentCulture.Clone() as System.Globalization.CultureInfo;
but it failed to make any effect, pdf file still had incorrect case and value in field AbbreviatedMonthNames of workbook.Settings.CultureInfo.DateTimeInfo will be changed to contain “мая”.

I did some more experiments and also found the following:
If I write the format as “ДД.МММ”(again, Cyrillic), cell will be displayed in Excel as “28.дек”, but after exporting it in pdf the value will be “28-дек”. “.” was changed into “-”.
Attached the archive with the xlsx file and the resulting pdf.
Aspose4.zip (41.1 KB)

@eospv,
Thanks for providing required information. We have logged it along with the ticket for our reference.

@eospv,

Please try our latest version/fix: Aspose.Cells for .NET v19.2.5 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.2.5 For .Net2_AuthenticodeSigned.Zip (4.8 MB)
Aspose.Cells19.2.5 For .Net4.0.Zip (4.8 MB)

Hello!
We tried the attached libraries and Excepion is no longer observed.
However, some formating problems remained.
I attached a screenshot comparing Excel and the resulting pdf where I highlighted the differences.
image.png (37.0 KB)

Original Excel file (DateTest.xlsx) is attached to my previous post.

@eospv,

We were able to observe the difference but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46628 - Difference in output PDF

@eospv,

For the formatted results of B1:E1, we have fixed them according to MS Excel’s display. However, for the weekday value of F2, we found different versions of MS Excel give different result. For MS Excel prior to 2016, the formatted value of weekday is same with what shown in your screenshot. However, in MS Excel 2016, the formatted result is same with our component. We think maybe it is a “bug” for old versions of MS Excel and has been fixed in Excel 2016, so we will not change the current behavior of the component.

@eospv,

@rajendrak,

This is to inform you that we have fixed your issue(s) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

The issues you have found earlier (filed as CELLSNET-46628,CELLSNET-46618) have been fixed in Aspose.Cells for .NET v19.3. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi