Setting a Document Property worked in 3.0 but not in 3.5.3

I just upgraded to Asposes 3.5.3. I am noticing that code that worked under Aspose version 3.0 no longer works. Previously, I was using Aspose.Excel.DocumentProperties to set the "Author" property. It worked. Now, using Asposes 3.5.3 that API does not appear to be supported, so I switched to using Aspse.Excel.BuiltInProperties, which seemed the new correct way to get at the "Author" property. The code compiles and runs, but the Author property is not changed in the output file. (The debugger thinks that the value is set, though.)

Could you please double-check this functionality and let me know what you think is happening? Thanks.

Thank you for the report and sorry for this bug.

We ported code to read document properties from windows API interop to full managed code. This problem may be caused by the porting. We will check and fix this issue ASAP.

It’s fixed. Please try this attached fix.

I am seeing odd behavior with the DLL patch. For all but one run of the exact same code, I get a NullReferenceException in Aspose.dll. Everything looks correct in the debugger (I see an Author string with all ASCII characters). I am passing valid values to Aspose.Excel.Save, code that has been working for a long time:

fileName = "E-320-7-50-705.xls"
SaveType = Aspose.Excel.SaveType
DefaultFileType = Excel2003
response = {System.Web.HttpResponse}

[NullReferenceException: Object reference not set to an instance of an object.]

at Aspose.Excel.RW.?.?(BuiltInDocumentProperties ?, CustomDocumentProperties ?, ? ?)\r\n
at Aspose.Excel.Worksheets.?(FileFormatType ?)\r\n
at Aspose.Excel.Worksheets.?(String ?, SaveType ?, FileFormatType ?, HttpResponse ?)\r\n
at Aspose.Excel.Excel.Save(String fileName, SaveType saveType, FileFormatType fileFormatType, HttpResponse response)\r\n

P.S. - I just noticed that when using version 3.5.3.0 (NOT the patch that gives the NullReferenceException), if I hover my mouse cursor over an Excel file that I generated, the Author property is shown. BUT the Author property appears blank if I open the Excel file and use File | Properties.

Could you please post your template file and sample code here? Thank you.

OK. I’ll try to do that today. In the interim, I just edited my posting (above). See the P.S.

In previous v3.5.3, we have also found the Author property shows correctly in windows explorer but doesn't show correctly in MS Excel. This bug is fixed.

For this NullException issue, I think it may relate to your template file.

I have attached a simple Unit Test that demonstrates the problem. If your environment does not support the Microsoft.VisualStudio.TestTools.UnitTesting namespace, just copy the 6 lines of code into your test bed and see the results.

// Results Summary:

// version 3.5.3.0 - Assertion fails. does not equal <>.

// version 3.5.3.1 - System.NullReferenceException: Object reference not set to an instance of an object.

Sorry for this problem. Please try this attached fix.

By the way, after you save the file, all contents in Excel object is re-initialized. So please change your test code to:

Excel asposeExcel = new Aspose.Excel.Excel();
BuiltInDocumentProperties properties = asposeExcel.Worksheets.BuiltInDocumentProperties;
properties.Author = "Test Author";
asposeExcel.Save("SetAuthorTest.xls");

asposeExcel.Open("SetAuthorTest.xls");

string author = asposeExcel.Worksheets.BuiltInDocumentProperties.Author;
Assert.AreEqual("Test Author", author);

The fix that you mention does not work, because the NullReferenceException is being thrown on this line:

asposeExcel.Save("SetAuthorTest.xls")

which is BEFORE the call to asposeExcel.Open().

I am using Visual Studio 2005 (version 8.0.50727.26) and the .NET Framework version 2.0.50727.

Please check if your project refers to the new dll. It’s v3.5.3.2.

Fixed! I’m not sure when the release bumped to 3.5.3.2. (I was testing with 3.5.3.1 – up from 3.5.3.0). In any case, the problem is resolved. Thank you.