We are using aspose to open excel files, insert a few (4) small pieces of data, and then saving the resulting file to a directory. For some reason, files that were working with Aspose.Cells 3.7 are now not working with 4.0.1.0 (which we installed to fix a copy and paste problem that was causing Excel to crash). The files become corrupted and when I attempt to open them using Excel 2000 I recieve the following message:
Microsoft Excel - [Name of file]: EXCEL.EXE - Application Error
The instruction at "0x301377a4" referenced memory at "0x0086edbc". The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
I have uploaded an example of a file that has been corrupted by this process. Note: the file contains macros, but the problem happens even if you disable them.
Here is the code we are using to open, edit, and save the file:
------------------------------
Private Function ExcelDownload(ByVal drDocument As DataRow) As Boolean
'set license for aspose.cells
Dim license As Aspose.Cells.License = New Aspose.Cells.License
license.SetLicense("Aspose.Custom.lic")
'create instance of aspose.cells.workbook
Dim objExcel As Aspose.Cells.Workbook = New Aspose.Cells.Workbook
Dim strDocumentName As String
Dim strDocumentFullPath As String
Dim strSaveFullPath As String
Dim strFullFileName As String
Dim drParameterList As DataRow()
Dim intPKPBorrowerID As Integer
Dim strDealRelationship As String
Dim strEntityIndividual As String
'get the name and path of the master spreadsheet
strDocumentName = drDocument.Item("DocumentName").ToString
strDocumentFullPath = drDocument.Item("DocumentFullPath").ToString
'get the name and path to which the spreadsheet should be saved
strSaveFullPath = drDocument.Item("SaveFullPath").ToString
'get the parameter information for the spreadsheet
drParameterList = pobjDocumentParameterList.GetParameterData(CInt(drDocument.Item("DocumentID")))
With drDocument
intPKPBorrowerID = CInt(.Item("PKPBorrowerID"))
strDealRelationship = .Item("DealRelationship").ToString
strEntityIndividual = .Item("EntityIndividual").ToString
End With
If Not strDocumentFullPath Is Nothing Then
objExcel.Open(strDocumentFullPath)
'use the parameter information to place data in the spreadsheet
For Each drParameter As DataRow In drParameterList
Select Case drParameter.Item("ParameterName").ToString
Case "DealID"
With objExcel.Worksheets("Download")
'blank out the dealid column header to tell the spreadsheet to automatically
'refresh the first time the spreadsheet is opened.
.Cells(drParameter.Item("ParameterPlace").ToString & "1").PutValue("")
'enter the dealid into row 2 of the given column (usually 'A')
.Cells(drParameter.Item("ParameterPlace").ToString & "2").PutValue(pintDealID)
End With
Case "PKPBorrowerID"
With objExcel.Worksheets("Download")
'enter the dealid into row 2 of the given column
.Cells(drParameter.Item("ParameterPlace").ToString & "2").PutValue(intPKPBorrowerID)
End With
Case "DealRelationship"
With objExcel.Worksheets("Download")
'enter the dealid into row 2 of the given column
.Cells(drParameter.Item("ParameterPlace").ToString & "2").PutValue(strDealRelationship)
End With
Case "EntityIndividual"
With objExcel.Worksheets("Download")
'enter the dealid into row 2 of the given column
.Cells(drParameter.Item("ParameterPlace").ToString & "2").PutValue(strEntityIndividual)
End With
End Select
Next drParameter
'create the subdirectories needed to save the spreadsheet to the specified location
CreateSubDirectories(Left(strSaveFullPath, strSaveFullPath.LastIndexOf("\")))
'save the new spreadsheet
objExcel.Save(strSaveFullPath)
'clean up Aspose.Excel
NAR(objExcel)
objExcel = Nothing
End If
'clean up
strDocumentName = Nothing
strDocumentFullPath = Nothing
strSaveFullPath = Nothing
strFullFileName = Nothing
ExcelDownload = True
End Function
-----------------------------------
Any ideas what we can do?
Theo