How do I save the excel sheet to a file? Dont see any reference to do this. Thanks in advanced.
Eric
Hi Eric,
Please refer to http://www.aspose.com/Products/Aspose.Excel/Api/Aspose.Excel.Excel.Save3.html
.
It does and it doesn’t. I’m using your sample code and here is what I’m doing:
I’ll change the select statement later but this is my sub
Private Sub CreateProductsList(ByVal excel As Excel)
excel.Open(“C:\datafeeds\pricewatch.xls”)
Me.dataTable1.Reset()
Me.oleDbSelectCommand1.CommandText = “SELECT DISTINCTROW Products.ProductName, " + _
" Categories.CategoryName, Products.QuantityPerUnit,Products.UnitsInStock " + _
" FROM Categories INNER Join Products ON Categories.CategoryID = Products.CategoryID” + _
" WHERE (((Products.Discontinued) = No)) Order by Products.ProductName"
Me.oleDbDataAdapter1.Fill(Me.dataTable1)
Dim sheet As Worksheet = excel.Worksheets(0)
sheet.Cells.ImportDataTable(Me.dataTable1, False, 0, 0)
sheet.Name = “Sheet 1”
While excel.Worksheets.Count > 1
excel.Worksheets.RemoveAt(excel.Worksheets.Count - 1)
End While
excel.Save(“datafeed.xls”, SaveType.OpenInBrowser, FileFormatType.Default, Me.Response)
End Sub
All I need for it to do is write that datafeed.xls file to c:\datafeeds\datafeed.xls (not the browser) and it has to be named Sheet 1. After that I should be good to go.
I’ve already purchased your product so I hope this works.
Thanks in advanced,
Eric Mindte
Hi Eric,
Please change last line of code to:
excel.Savec:\datafeeds\datafeed.xls, FileFormatType.Default)
But since our demo is a web application, please be sure it has the authority to write file to c:\datafeeds directory.
You can also download our winform demo at
.
Yes that worked. It’s strange but I did try that before and it threw an exception and I just couldn’t determine it.
Thanks again,
Eric