I’ve recently migrated from the 4.7 version to the 7.2 on 2 web applications. During developpement, it worked out fine for both, but now one of the webapps made it to the test server and it has a problem that seems kind of obscure.
#Region “Export matrices”
Private Sub imgBtnExpExcel_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgBtnExpExcel.Click
If ddlDivision.SelectedValue <> String.Empty Then
Dim trans As OracleTransaction
Dim donnees As DataTable
Dim conn As New OracleConnection(ConfigurationSettings.AppSettings.Get(“ConnectionStringODP”))
Try
conn.Open()
trans = conn.BeginTransaction()
donnees = WrkfDB.SelectionMatricePourExportExcel(ddlDivision.SelectedValue)
trans.Commit()
Catch ex As Exception
If Not trans Is Nothing Then
trans.Rollback()
End If
Throw ex
Finally
conn.Close()
End Try
Dim resp As HttpResponse = HttpContext.Current.Response
resp.Clear()
Dim AsposeLicence As New Aspose.Cells.License
Dim license As String = “…/resources/licences/Aspose.Cells.lic”
AsposeLicence.SetLicense(license)
Dim excelBook As New Workbook
Dim excelSheet As Worksheet = excelBook.Worksheets(0)
InitStyleEntete(excelBook)
InitStyleDonnee(excelBook)
EcrireEntetes(excelSheet)
EcrireDonnees(excelSheet, donnees)
excelSheet.AutoFitColumns()
excelSheet.AutoFitRows()
Dim filename As String = String.Format(rm.GetString(“admin_fichier_export_matrice”), ddlDivision.SelectedValue, Utils.yyyyMMddhhmmss)
'excelBook.Save(filename + “.xlsx”, FileFormatType.Xlsx, SaveType.OpenInExcel, resp)
'FFT5484
excelBook.Save(resp, filename + “.xlsx”, Aspose.Cells.ContentDisposition.Attachment, New XlsSaveOptions(Aspose.Cells.SaveFormat.Xlsx))
resp.End()
End If
End Sub
Private Sub InitStyleDonnee(ByVal excelBook As Workbook)
Me._styleDonnee = excelBook.Styles(excelBook.Styles.Add())
Me._styleDonnee.Pattern = BackgroundType.Solid
Me._styleDonnee.Font.Size = 8
Me._styleDonnee.Font.IsBold = True
Me._styleDonnee.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thin
Me._styleDonnee.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thin
Me._styleDonnee.Borders(BorderType.RightBorder).LineStyle = CellBorderType.Thin
Me._styleDonnee.Borders(BorderType.LeftBorder).LineStyle = CellBorderType.Thin
Me._styleDonnee.IsTextWrapped = True
Me._styleDonnee.ShrinkToFit = False
End Sub
Private Sub EcrireDonnees(ByRef excelSheet As Worksheet, ByVal donnees As DataTable)
If donnees.Rows.Count > 0 Then
Dim col As Integer = 1
Dim row As Integer = 0
Dim str As String = String.Empty
Dim excelCell As Cell = Nothing
Dim i As Integer = 0
Dim j As Integer = 0
For j = 0 To donnees.Rows.Count - 1
Dim dataRow As DataRow = donnees.Rows(j)
For i = 0 To NB_LIGNES_MATRICE - 1
excelCell = excelSheet.Cells(row, col)
'FFT5484
excelCell.SetStyle(Me._styleDonnee)
'remplacement des 0//1 par des oui/yes//non/no
If i = 1 Then
str = OutilDB.DBNull(dataRow(“Used”))
str = IIf(str = “1”, rm.GetString("_rdok"), rm.GetString("_rdno"))
ElseIf i = 13 Then
str = OutilDB.DBNull(dataRow(“AutoDesignation”))
str = IIf(str = “1”, rm.GetString("_rdok"), rm.GetString("_rdno"))
Else
str = OutilDB.DBNull(dataRow(i))
End If
excelSheet.Cells(row, col).PutValue(str)
row = row + 1
Next
col = col + 1
row = 0
Next
End If
End Sub
Private Sub InitStyleEntete(ByVal excelBook As Workbook)
Me._styleEntete = excelBook.Styles(excelBook.Styles.Add())
Me._styleEntete.ForegroundColor = ColorTranslator.FromHtml("#CCCCCC")
Me._styleEntete.Pattern = BackgroundType.Solid
Me._styleEntete.Font.Size = 8
Me._styleEntete.Font.IsBold = True
Me._styleEntete.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thin
Me._styleEntete.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thin
Me._styleEntete.Borders(BorderType.RightBorder).LineStyle = CellBorderType.Thin
Me._styleEntete.Borders(BorderType.LeftBorder).LineStyle = CellBorderType.Thin
Me._styleEntete.IsTextWrapped = True
Me._styleEntete.ShrinkToFit = False
End Sub
Private Sub EcrireEntetes(ByRef excelSheet As Worksheet)
'Entête = titres des colonnes
Dim excelCell As Cell = Nothing
Dim col As Integer = 0 'indice des colonnes effectivement exportées
Dim row As Integer = 0
Dim i As Integer = 0
For i = 0 To NB_LIGNES_MATRICE - 1
excelCell = excelSheet.Cells(row, col)
excelCell.PutValue(String.Empty)
'FFT5484
excelCell.SetStyle(Me._styleEntete)
row = row + 1
Next
row = 0
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblSite”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblUsed”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblActivity”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblCategory”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblProductType”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lbl1stCriteria”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lbl2ndCriteria”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lbl3rdCriteria”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh1Marketing”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblCompTreatement”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblCompTService”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblProcessOwner”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblProProService”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblAutoDesignation”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPilot”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh2Purchase”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh2Management”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh2IndusMethods”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh2CentralLog”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh2SiteLog”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh2SIS”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh2PPPS”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh3GRAGDT”))
row = row + 1
excelSheet.Cells(row, col).PutValue(rm.GetString(“afv_export_matrice_lblPh3Management”))
End Sub
#End Region
While migrating from 4.7 to 7.2 several changes were made to the code, mainly concerning:
- cell styles and the way they were applied
- save file method
I’m kind of lost with this error. Any input will be much appreciated.
Thanks,
Alin