We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

InvalidCastException: Can''t convert value to string

I get this exception when I try to save a xls file.
Is this a known issue?


System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Can't convert value to string.
at Syncfusion.CompoundFile.XlsIO.DocumentPropertyImpl.get_Text()
at Syncfusion.XlsIO.Implementation.WorkbookImpl.get_Author()
at Syncfusion.XlsIO.Implementation.WorkbookImpl.WorkbookExcel97Serializator.Serialize(OffsetArrayList records, ExcelSaveType saveType, IEncryptor encryptor, WorkbookImpl book, WorksheetImpl sheet, Boolean forClipboard)
at Syncfusion.XlsIO.Implementation.WorkbookImpl.WorkbookExcel97Serializator.Serialize(Stream stream, WorkbookImpl book, ExcelSaveType saveType)
at Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(Stream stream, ExcelSaveType saveType)
at Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(Stream stream)


Regards
Dan Ove


5 Replies

SR Sridhar Syncfusion Team January 10, 2011 08:49 AM UTC

Hi Dan,

Thank you very much for using Syncfusion products.

The exception posted in the last update seems to be occurred while parsing or serializing the document properties of the Excel file. Could you please update us the below details to proceed further on this issue.

Details required:
1)Whether the exception occurs while reading an existing file or creating a new file.
2)If it occurs while creating a new file, can you please update us the code snippet you have tried at your side.
3)If it occurs while reading from an existing file, can you please update us the issue reproducing Excel file.
4)Currently using Syncfusion Essential studio version.

Please let us know if you need any clarifications.

Thanks,
Sridhar S




DO Dan Ove Aalstad January 21, 2011 11:03 AM UTC

Hi

We are still investigating the issue. The error occurs after we have opened an existing FileStream, changed some text and save the changes back to a new Stream.

The problem is that the bug only affects some users (PC's) so it is difficult to debug.

Regards

Dan Ove



SR Sridhar Syncfusion Team January 24, 2011 12:03 PM UTC

Hi Dan,

Thanks for the update.

The error occurs when reading and writing the streams of the file you are using.Could you please send us the sample you are using and the code snippet for read/write of an Filestream. So that we can move further analysing on this issue.

Please let us know if you need any clarifications.

Thanks,
Sridhar S




DO Dan Ove Aalstad February 14, 2011 08:47 AM UTC

Hi

It seems that I made a workaround to the issue.
I haven’t got any more exceptions after I added a line that set the author after opening the workbook. This workaround is tested in 8.4.0.10. I haven’t upgraded and tested 9.1.0.20 yet.

IWorkbook workbook = application.Workbooks.Open(documentStream);
workbook.Author = unitOfWork.Session.CurrentUser.FullName;




SR Sridhar Syncfusion Team February 14, 2011 12:46 PM UTC

Hi Dan,

Thanks for the update.

If possible, could you please update us with the simplified issue reproducing sample and the input template, so that we will fix this issue and update you with the patch.

Please let us know if you have any clarifications.

Thanks,
Sridhar.S


Loader.
Live Chat Icon For mobile
Up arrow icon