Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Apr 26, 2012 6:31 pm

Hi,

I am using spire.Office (Xls and PdfConverter etc) in a pop email collection system which is intended to automatically convert incoming attachments to pdf for inclusion to a document management system backend.

Anyway there is a particular xlsx file being sent in by a regular user which tends to break my script.

My code is as follows:

Workbook workbook = new Workbook();
workbook.Version = ExcelVersion.Version2007;
workbook.LoadFromStream(attachment.DataStream());
PdfConverter pdfConverter = new PdfConverter(workbook);
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.PageSettings.Orientation = Spire.Pdf.PdfPageOrientation.Portrait;
pdfDocument.PageSettings.Size = Spire.Pdf.PdfPageSize.A3;
pdfDocument.PageSettings.Margins.All = 10;
PdfConverterSettings settings = new PdfConverterSettings();
settings.TemplateDocument = pdfDocument;
settings.DisplayGridLines = PdfConverterSettings.GridLinesDisplayStyle.Invisible;
settings.EmbedFonts = true;
settings.ExportDocumentProperties = true;
pdfDocument = pdfConverter.Convert(settings);
pdfDocument.SaveToFile(HttpContext.Current.Server.MapPath("~/messages/") + msgAttach.Msg_id.ToString() + ".pdf");

The offending xlsx file is attached. I know it is a nonsensical use of Excel for the contents of the file but I am unable to control that aspect unfortunately. Sorry the forum doesnt allow me to attach xlsx files.

The error I am getting is as follows:
[ArgumentNullException: Value cannot be null.
Parameter name: root]
Spire.CompoundFile.XLS.Native.Storage..ctor(IStorage root, String storageName) +171
Spire.CompoundFile.XLS.Native.Storage..ctor(IStorage root) +35
Spire.CompoundFile.XLS.Native.CompoundFile.a(Stream A_0) +187
Spire.Xls.Core.Spreadsheet.XlsApplication.CreateCompoundFile(Stream stream) +62
Spire.Xls.Core.Spreadsheet.XlsWorkbook.a(Stream A_0, String A_1, ExcelVersion A_2, ExcelParseOptions A_3) +104
Spire.Xls.Core.Spreadsheet.XlsWorkbook.a(String A_0, String A_1, ExcelVersion A_2, ExcelParseOptions A_3) +82
Spire.Xls.Core.Spreadsheet.XlsWorkbook..ctor(IInnerApp application, Object parent, String strFileName, ExcelParseOptions options, Boolean bReadOnly, String password, ExcelVersion version) +291
Spire.Xls.Core.Spreadsheet.XlsApplication.CreateWorkbook(Object parent, String strTemplateFile, ExcelParseOptions options, Boolean bReadOnly, String password, ExcelVersion version) +51
Spire.Xls.Core.Spreadsheet.Collections.XlsWorkbooksCollection.Open(String fileName, ExcelParseOptions options, Boolean isReadOnly, String password, ExcelVersion version) +42
Spire.Xls.Workbook.LoadFromFile(String fileName, ExcelVersion version) +122
Spire.Xls.Workbook.LoadFromFile(String fileName) +39
mailroom_test.convertor(Object sender, EventArgs e) in c:\inetpub\demo\mailroom\test.aspx.cs:25
mailroom_test.Page_Load(Object sender, EventArgs e) in c:\inetpub\demo\mailroom\test.aspx.cs:17
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

dtwilson
 
Posts: 2
Joined: Mon Dec 05, 2011 12:45 pm

Fri Apr 27, 2012 1:29 am

Hi ,
So sorry for the inconvenience.

Please send the xlsx file to support@e-iceblue.com. Our technical support will test it and fix it ASAP.

Have a nice day!

BR
Suvi
e-iceblue support
User avatar

Suvi.Wu
 
Posts: 154
Joined: Thu Oct 20, 2011 2:53 am

Fri Apr 27, 2012 9:32 am

Thanks Suvi,

I've emailed the file in as requested so look forward to feedback.

David

dtwilson
 
Posts: 2
Joined: Mon Dec 05, 2011 12:45 pm

Thu Jun 28, 2012 3:09 am

Hi David,

Thanks, you will be notified via when the issue fixed.
e-iceblue support
User avatar

iceblue support
 
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Return to Spire.XLS