Workbook.importXml() issue with boolean type

The issue I have reported for the date type seems also touching boolean type. If in a schema the element is a boolean and binded to a cell. When a document is bound and it contains boolean value , the resulting cell type in excel is a string and not a boolean.
In the project we use check box control , when the boolean value are bound to a cell, the type must be a boolean and not a string as today. I have compared with Microsoft implementation using the import feature in excel, the type is a boolean. Could you have a look in this issue and include it with the release you are doing for the date type.

@apacifico1,

Could you please provide us (zip and attach) sample code and sample files to reproduce the issue as you described. We will check your issue soon.

testcaseforaspose.zip (13.1 KB)
You will find attached in the zip , the excel file template for the test having a schema mapped. I have also attached the schema file and an xml data file to test the mapping. The focus are the cells B2 and B5 defined as boolean in the schema. The importxml function after import the cells are transformed in string type. Excel import feature provided by MS doesn’t change the type of the data imported following the schema. if you do a type(B2) with Microsoft you obtain 4 => boolean and after aspose importxml the same method returns 2 meaning a string. Hope this sample will help you to reproduce the issue.

@apacifico1,

Thanks for the template file and XML file with details.

Please notice, I am able to reproduce the issue as you mentioned by using the following sample code with your template file and XML file. I found the Boolean value is not inserted as Boolean type. Rather it is inserted as text/string type.
e.g.
Sample code:

            using (Workbook lWorkBook = new Workbook("e:\\test2\\TestFileWithSchema.xlsx"))
            {
                var lWorksheet = lWorkBook.Worksheets[0];
                System.Xml.XmlDocument document = new System.Xml.XmlDocument();
                document.Load("e:\\test2\\TestData.xml");
                System.IO.Stream stream = new System.IO.MemoryStream();
                document.Save(stream);
                stream.Position = 0;

                lWorkBook.ImportXml(stream, "General", 0, 0);
                lWorkBook.Save("e:\\test2\\out1.xlsx");
            }

I have logged a separate ticket with an id “CELLSNET-51197” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

Thanks a lot for your rapid feedback. In the project we are doing the schema could contain delement with different type. The datatime is one of them and we have identified and issue and now for the boolean type. Could you group in the comming release the fix related to these two types? We would be sure we can cover all the type we manipulate in the schema.

@apacifico1,

We understand your concerns. We will try to figure out the issue regarding Boolean type as well in the coming release. But we need to first evaluate your issue in details. Please spare us little time to properly analyze the issue. Once we have an update on it, we will let you know here.

@apacifico1

We have fixed importXml issue for boolean type. see the preview result with hotfix:output_hotfix_preview.zip (12.4 KB)

However, for the date filed “A10:A12”, there are date format in the source file. After importing xml, there are difference between the Microsoft Excel generated file and Aspose.Cells generated one. see screenshot: Screenshot_comparing.png (72.1 KB).
The format of "A10:A12"is overwriten in the Microsoft Excel generated file, but the fomat is kept as origin in the Aspose.Cells generated file.

Thanks a lot for this hot fix. So Microsoft overwrite the date format of the cell , but with the Aspose implementation the original format is kept. It’s good because in any case I don’t want modify the presentation defined by the user for the cells.
In fact I realized the hotfix preview is not included. You provided only the workbook to show the result with the hotfix. How to get the hotfix or I need to wait the official release?
Thanks alot again for your work.

@apacifico1,

Good to know that you accepted the preview results of the upcoming release (hotfix).

The fix will be included in the (upcoming) release (Aspose.Cells for .NET v22.6), which is scheduled to be published before the end of this week or in the next week early. You will also be notified when the next version is released.

The issues you have found earlier (filed as CELLSNET-51197) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

Dear aspose.team I have tested the new release 22.6asposetestcase.zip (292.7 KB)

I provided the test case. You will found test2.xml I import via the feature and I use the template Front_Page.xlsm.

The following code is a sample of the code we use to do the action with aspose.cells. It’s the same code we used with the version 22.5

        using (FileStream file = new FileStream(@"C:\temp\ExcelTestDriver\test2.xml", FileMode.Open, FileAccess.Read))
            file.CopyTo(xmlms);
        xmlms.Position = 0;
        doc.ImportXml(xmlms, curMetaData.ExcelSheetName, 0, 0);
        doc.CalculateFormula();
        doc.Save(directory + "\\" + fileName + "." + format, format);

The OUT file are the result of the import. Sometime the file produced is correct (the long size) sometime the file is not readable by Excel. It’s a a file containing macro and as you can see we need to re-evaluate formula before to save it. It’s difficult to reproduce systematically but I don’t understand, with the same code and the same data , sometime produce a file not readable. Could you have a look? I repeat the same code is used when we was working with the version 22.5. When the file is produced correctly the boolean are set and the date too, so it’s a good progress but at the same time obtaining a file not readable at all by Excel is not good.

@apacifico1,

Thanks for the resource files.

We will check your issue and get back to you soon.

I am sorry to have reported this issue. In fact the issue came from my data. After restarting from a fresh case, I can generate the workbook and the xml data are correctly mapped. I confirm the boolean are correctly mapped and also the date field.
But the issue sometime turn. Is it possible with a temporary licence to have issues? In my case it’s a web service that run and the temporary license I use will expire in July. When the issue appears it seam the file is truncated, the size is small compared to a good file. The issue happen also when I work with sharepoint. Excel says the file is corrupted when opened from sharepoint, but if the file is downloaded on my local drive , excel can open it without issues.

@apacifico1,

I tested your scenario/case using your sample XML file and template XLSM file with the following sample code and it works fine. The output file (attached) is ok and can be opened fine into MS Excel:
e.g.
Sample code:

            using (Workbook lWorkBook = new Workbook("e:\\test2\\Front_Page.xlsm"))
            {
                System.Xml.XmlDocument document = new System.Xml.XmlDocument();
                document.Load("e:\\test2\\test2.xml");
                System.IO.Stream stream = new System.IO.MemoryStream();
                document.Save(stream);
                stream.Position = 0;

                lWorkBook.ImportXml(stream, "FRONT PAGE", 0, 0);
                lWorkBook.Save("e:\\test2\\out1.xlsm");
            }

files1.zip (83.3 KB)

I do not think it is due to temp license. The temporary license is a valid license similar to professional license except it expires after 30 days.

Between the load and the save in my exemple I use the calculateformula to re-evaluate some cells in the workbook. You can see this in the sample of code I have provided. Is it possible the issue can come from this calculate? I did again test generating the file and the file can be opened with success. I think I have an issue perhaps with sharepoint integration, saying the file is corrupted but when the file is downloaded the file can be opened. Some people reported issues between sharepoint and excel file with macro. I continue to investigate on my side.

I do not think the issue is due to this. Anyways, we need to evaluate it thoroughly.

Thanks for evaluating it on your end. You may share your findings here after testing it thoroughly. By the way, could you please use your code (file saving) in some loop to generate file(s) multiple times (say generate 5 similar files by Aspose.Cells) in one go and then evaluate/check how many files are good and how many files are bad (corrupted)?

@apacifico1
Please try 22.6.1 (NUMBERS Data Storage 5.0 Support API for C#, ASP.NET Apps)