Free Support Forum - aspose.com

Excel version problem with 2003 and 2007

Hey all,

I ran into an interesting use case. We generate excel 2003 files programatically using Aspose for our users. They make changes to the excel document and then upload it back and we process the changes. The problem case I found was when a user has excel 2007 installed and they open up our 2003 file and then save their changes the .xls file gets saved as .xlsx. When the user uploads the file back to use we get the following exception from the .Open command.

Any ideas? Im using the latest trial version of Aspose.Cells.

string path = @"C:\Book1.xlsx";

Workbook workbook = null;

try

{

workbook = new Workbook();

workbook.Open(path, FileFormatType.Excel2007Xlsx); // <== exception thrown here

}

System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Cells.OpenXML.xa969cda0bb1fbd14.x86f0c25c32dda935()
at Aspose.Cells.OpenXML.xa969cda0bb1fbd14.x06b0e25aa6ad68a9(XmlTextReader xb9763b0038341e6c)
at Aspose.Cells.OpenXML.xe95a61e48a6637a3.x2e7f798eabefe5b4(Workbook xce16031e3118b903, Stream xcf18e5243f8d5fd3)
at Aspose.Cells.Workbook.Open(Stream stream, FileFormatType type)

Hi,

Could you post your file? We will check it soon.

I zipped it up in order to upload it to you.

Thanks

Hi,

Thanks for Template file.

We checked your template file. There are still some features which are not supported for Excel 2007 xlsx files yet. For example, your template contains Auto-Filter feature which is not supported yet. We are working on them (including this feature), hopfully these features will be available soon.

Thanks for your patience.

I see. Please let me know when these features become available as I have customers who are very eager to use Excel 2007.

Hi,

Thanks for considering Aspose.

We will update you soon.

Thank you.

Hi tkaufman,

Excel 2007 feature Autofilter will be supported in the next fix that may be available this week. We are doing some test on it. Thank you for your patient.

Regards


Karen.huang
Developer
Aspose Nanjing Team
About Us
Contact Us

Hi,

Please try the attached fix, we repaired the problem and added Autofilter feature in this fix. Thanks for being patient!


Karen.huang
Developer
Aspose Nanjing Team
About Us
Contact Us

That fixed that issue, and led me to another :-)

Once I have loaded the excel 2007 document I have logic which checks the IsLocked property of a cell. All cell styles IsLocked property are set to true. I have attached the file I am using for testing.

// If cell is not locked

if (forecastDataRange[x, y].Style.IsLocked == false) {

// DO SOME PROCESSING ON THAT VALUE

}

In order for my company to use Aspose.Cells and truely support our excel 2007 user base we need the protection properties at a cell level to behave the same as it does in 2003 format as well as the comments in a cell.

As of now that seems to be the final set of hurdles for us.

Hi,

Thanks for considering Aspose.

Well, We are working on the feature and we will soon support Protection feature for MS Excel 2007 .xlsx file format.

Thank you.

Hi,

Please try the attached fix. We added Protection feature in this fix.

Regards

---------------------

Karen.huang
Developer
Aspose Nanjing Team
About Us
Contact Us

This is still not working as expected. My procedure is as follows. I programatically create an excel 2003 document which the user downloads. In some cases the user opens this file in excel 2007 and saves the file in 2007 format.

The user uploads that document (now its an .xlsx) file. I look at the Cells[x,y].Style.IsLocked property and that value is always coming at "true". This is not correct because even though the sheet is locked there are some cells which are not.

Hi,

We tested the Cells[x,y].Style.IsLocked property and it works fine. The attached file c.xlsx is created with MS Excel 2007. Please try the following code:

private static void testProtection()

{

string baseFn = "c.xlsx";

string basePath = @"E:\temp\";

string inFn = basePath + baseFn;

Workbook wbook = new Workbook();

wbook.Open(inFn, FileFormatType.Excel2007Xlsx);

Worksheet sheet = wbook.Worksheets["sheet1"];

bool b = sheet.Cells["A5"].Style.IsLocked;

Console.WriteLine(b); // it should prints True

b = sheet.Cells["A6"].Style.IsLocked;

Console.WriteLine(b); // it should prints Flase

Console.ReadLine();

}

Please ensure the version you are using is the one I attached in the posting 10-26-2007, 12:58 PM. If you still find the problem, kindly post your template file with sample code here.

Thank you.

---------------------

Karen.huang
Developer
Aspose Nanjing Team
About Us
Contact Us

That version (4.4.0.12) worked with the excel 2003 and 2007 versions! Thank you!

Im not sure if this is the proper thread to add this onto, but I noticed some other functionality that no longer works with this version.

I use aspose cells to create an excel document. I add Styles to the workbook and then save it out to a byte[]. A separate process reads that byte[] back into an Aspose Workbook and then attempts to use one of the workbook styles added by the first process.

The result is NULL when I access the previously set Style

Ex: workbook.Styles[HEADER_STYLE_NAME].

This functionality worked in the Aspose.Cells.dll version (4.4.0.5).

Is there a more recent version of Aspose.Cells I can try this out? The download pages only show 4.4.0.0.....

Hi,

It's caused by that we don't copy the name of the style again in the Style.Copy method.

Please try this fix.

ThanksWarren. That solved the issue.