Hi, I'm trying to test to see how well Excel (old version) to Cells work. This line of code below worked well under Excel but when I try using Cells, nothing gets populated in the spreadsheet cells
If Not IsDBNull(MyReader("MTDSTAT")) Then Excel.Worksheets(0).Cells(CellRow2, CellCol).PutValue(Val(MyReader("MTDSTAT")))
There are values returning from the Store procedure:
{Aspose.Cells.Cell [ N37; ValueType : IsNumeric; Value : 1155 ]}
The spreadsheet pops up but it's blank and gives no error messages.
I will require your complete project replicating this issue without database dependency. If you have any database values, then replace them with hard-coded sample test values.
Anyway, I have written the following code to test your issue with a similar code, as you can see, it is working fine.
Please see the output.xlsx generated by this code.
Ok I put Excel.Save("output.xlsx", Aspose.Cells.SaveFormat.Xlsx) that thatmshakeel.faiz had in your code and it saves fine so verifying it saves correctly using that line of code, I went back into my application to figure out how my application save and found this.
This is the original code:
ReportName = ReportName +".xls"
excel.Save(ReportName,FileFormatType.Default,SaveType.OpenInExcel,Me.Response)'this is the old excel aspose.
Now I try implementing the new Aspose.Cells dll
Dim wb As Aspose.Cells.Workbook = New Aspose.Cells.Workbook
Error 16 Overload resolution failed because no accessible 'Save' can be called without a narrowing conversion: 'Public Sub Save(fileName As String, saveType As Aspose.Cells.SaveType, fileFormatType As Aspose.Cells.FileFormatType, response As System.Web.HttpResponse)': Argument matching parameter 'saveType' narrows from 'Aspose.Excel.FileFormatType' to 'Aspose.Cells.SaveType'. 'Public Sub Save(fileName As String, saveType As Aspose.Cells.SaveType, fileFormatType As Aspose.Cells.FileFormatType, response As System.Web.HttpResponse)': Argument matching parameter 'fileFormatType' narrows from 'Aspose.Excel.SaveType' to 'Aspose.Cells.FileFormatType'. 'Public Sub Save(fileName As String, fileFormatType As Aspose.Cells.FileFormatType, saveType As Aspose.Cells.SaveType, response As System.Web.HttpResponse)': Argument matching parameter 'fileFormatType' narrows from 'Aspose.Excel.FileFormatType' to 'Aspose.Cells.FileFormatType'. 'Public Sub Save(fileName As String, fileFormatType As Aspose.Cells.FileFormatType, saveType As Aspose.Cells.SaveType, response As System.Web.HttpResponse)': Argument matching parameter 'saveType' narrows from 'Aspose.Excel.SaveType' to 'Aspose.Cells.SaveType'. C:\VBtest\programming\PRACTICEProgramming\INDIVIDUALprograms\webmis\ReportView.aspx.vb 281 17 C:\...\webmis\
Ok I did managed to declare it correctly at one point but thought I didn't do it correctly because I can't manage to load the premade Spreadsheet (SS).
1. The data does populate in the SS fine (just a blank template as the style) using aspose.cells.
2. Using the old excel.aspose dll works and the premade SS is populated with the data but using the new aspose.cells don't
string filepath = c:\spread.xls
Dim wb As Aspose.Cells.Workbook = New Aspose.Cells.Workbook()
Dim wbPath As Aspose.Cells.Workbook
Try
If filepath <> "" Then wbPath = New Aspose.Cells.Workbook(filepath)
Select Case ReportID
Case 1000, 1170, 1370
End Select
ReportName = testSpreadSheet + ".xls"
wb.Save(HttpContext.Current.Response, ReportName, Aspose.Cells.ContentDisposition.Attachment, New Aspose.Cells.XlsSaveOption(Aspose.Cells.SaveFormat.Excel97To2003))
Actually, the workbook which you are sending to response stream is empty, your correct code will be like this.
This code will send your premade Spreadsheet (SS) to response stream.
VB.NET
string filepath = c:\spread.xls
Dim wbPath As Aspose.Cells.Workbook
Try
If filepath <> “” Then wbPath = New Aspose.Cells.Workbook(filepath)
SelectCase ReportID
Case 1000, 1170, 1370
EndSelect
ReportName = testSpreadSheet + “.xls”
wbPath.Save(HttpContext.Current.Response, ReportName, Aspose.Cells.ContentDisposition.Attachment, New Aspose.Cells.XlsSaveOption(Aspose.Cells.SaveFormat.Excel97To2003))