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.
Unfortunately, activation email could not send to your email. Please try again.

Value Cannot Be Null error

Thread ID:

Created:

Updated:

Platform:

Replies:

77049 Oct 9,2008 04:07 PM Aug 30,2012 02:20 AM Windows Forms 3
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On October 9, 2008 04:07 PM

I've written the following code:
Dim fn As String = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)
Dim SaveLocation As String = Server.MapPath("data") & "\" & fn
Dim test = ResolveApplicationDataPath("combinedTest.xls")

If Not FileUpload1.PostedFile Is Nothing And FileUpload1.PostedFile.ContentLength > 0 Then
FileUpload1.PostedFile.SaveAs(SaveLocation)
Else
Response.Write("Please select a file to upload.")
Response.Write("The file has been uploaded.")
End If

Dim excelengine As ExcelEngine = New ExcelEngine()
Dim application As IApplication = excelengine.Excel
Dim workbook As IWorkbook = application.Workbooks.Open(SaveLocation)
Dim sheet As IWorksheet = workbook.Worksheets(0)
Dim sheettable As DataTable = sheet.ExportDataTable(sheet.UsedRange, ExcelExportDataTableOptions.ColumnNames)
Me.GridView1.DataSource = sheettable
Me.GridView1.DataBind()
workbook.Close()
excelengine.ThrowNotSavedOnDestroy = False
excelengine.Dispose()

'Response.Write(location)

When I run it, I get:
Value cannot be null.
Parameter name: root

Line 65: Dim excelengine As ExcelEngine = New ExcelEngine()
Line 66: Dim application As IApplication = excelengine.Excel
Line 67: Dim workbook As IWorkbook = application.Workbooks.Open(SaveLocation)
Line 68: Dim sheet As IWorksheet = workbook.Worksheets(0)
Line 69: Dim sheettable As DataTable = sheet.ExportDataTable(sheet.UsedRange, ExcelExportDataTableOptions.ColumnNames)

The stack trace:
[ArgumentNullException: Value cannot be null.
Parameter name: root]
Syncfusion.CompoundFile.Native.Storage..ctor(IStorage root, String storageName) +133
Syncfusion.CompoundFile.Native.Storage..ctor(IStorage root) +35
Syncfusion.CompoundFile.Native.CompoundFile.Open(Stream stream) +276
Syncfusion.CompoundFile.Native.CompoundFile..ctor(String fileName, STGM options) +153
Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateCompoundFile(String fileName, STGM storageOptions) +55
Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, String strFileName, ExcelParseOptions options, Boolean bReadOnly, String password, ExcelVersion version) +380
Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, String strFileName, ExcelParseOptions options, ExcelVersion version) +67
Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, String FileName, ExcelVersion version) +62
Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook(Object parent, String strTemplateFile, ExcelVersion version) +51
Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(String filename, ExcelVersion version) +49
Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(String filename) +58
_Default.Button2_Click(Object sender, EventArgs e) in C:\Documents and Settings\rsteckly\My Documents\Visual Studio 2008\WebSites\WebSite6\Default.aspx.vb:67
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

I don't see what's wrong with this. I've tried testing to see what the samples for XLSIO produce for a path to a file. It's still fundamentally a string to a file. Why then would it throw a null exception?


Geetha M [Syncfusion]
Replied On October 10, 2008 05:36 AM

Hi Ron,

Thank you for your interest in Syncfusion products.

I was not able to reproduce the issue. I have created a sample using your code snippets and it is working fine for me. You can check it in the following link:

http://websamples.syncfusion.com/samples/XlsIO.Web/6.3.1.8/I50411/main.htm

Could you please try running the sample from the above link? If you still face issue, please send us your file so that it would help us to find the cause of the problem.

Please let me know if you have any concerns.

Regards,
Geetha


Yuri van Oers
Replied On December 3, 2008 04:23 AM

Had the same problem.
Using
application.Workbooks.Open(SaveLocation, ExcelOpenType.Automatic) fixed the issue for me.

(Am using v6.402.0.15 and C#)


Sridhar [Syncfusion]
Replied On August 30, 2012 02:20 AM

Hi Yuri van Oers ,
 
We are sorry for the delay in getting back to you.
 
Please let us know whehter the above reported is solved at your side and let us know if you require any further assitance on this.
 
Thanks,
Sridhar.S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;