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

xlsio saveas

Hi,

I am using XlsIO to export data from datatable to excel. Everything works fine but it errors out at .saveas. Also I am not sure what to be entered for Response in the workbook.Saveas parameter.

Please advice.

Thanks,
Navin

Below is the code:

Shared Sub ExportValidation(ByVal tblName As String)
Dim oleAdp As OleDbDataAdapter
Dim ds As DataSet
Dim dt As DataTable

Dim sql As String = "SELECT * FROM tbl" & tblName

oleAdp = New OleDbDataAdapter(sql, cnn)
ds = New DataSet
oleAdp.Fill(ds)

dt = New DataTable
dt = ds.Tables(0)

Dim excelEngine As ExcelEngine = New ExcelEngine
Dim application As IApplication = excelEngine.Excel
application.DefaultVersion = ExcelVersion.Excel97to2003

Dim wbk As IWorkbook = application.Workbooks.Create(1)
Dim wks As IWorksheet = wbk.Worksheets(0)

If Not dt.Rows.Count = 0 Then
wks.ImportDataTable(dt, True, 1, 1)
End If

wbk.SaveAs("ContactValidationOutput.xls", ExcelSaveType.SaveAsXLS, Response, ExcelHttpContentType.CSV)
wbk.Close()
excelEngine.Dispose()

End Sub


1 Reply

SR Sridhar Syncfusion Team October 7, 2011 08:40 AM UTC

Hi Navin,

Thank you for using Syncfusion products.

We are unable to reproduce the reported issue at our side. We have tried the sample at our side to reproduce the above reported issue by importing the data table and saveas method and we are not able to see any issues at our side with that sample.
We have attached the sample for your reference.

Please try the sample at your side and let us know if these helps you. If you still face the issue, please get back to us with the simplified sample and the stack trace for the reported error.

Please let me know if you require any further clarifications.

Thanks,
Sridhar.S



SaveAs_786ae38f.zip

Loader.
Live Chat Icon For mobile
Up arrow icon