Merci pour cette réponse rapide mais j'ai déjà essayé de cette manière et malheureusement ca ne fonctionne pas
: le Style de la cellule à traiter me renvoie toujours Nothing. C'est pour ça que j'aimerai récupérer les infos directement dans la feuille de style CSS car j'arrive bien à récupérer la CssClass de la cellule...
Voici mon code, si ca peut aider :
la construction de la table :
Private
Sub DisplayReporting(ByVal dr As SqlDataReader)
Dim MyRow As TableRow
Dim MyCell As TableCell
While
dr.Read
MyRow = New TableRow
'cellule 1
MyCell = New TableCell
MyCell.CssClass = dr("CELL1_CSS").ToString
MyCell.Text = dr("CELL1_TEXT").ToString
MyRow.Cells.Add(MyCell)
'cellule 2
MyCell = New TableCell
MyCell.CssClass = dr("CELL2_CSS").ToString
MyCell.Text = dr("CELL2_TEXT").ToString
MyRow.Cells.Add(MyCell)
'cellule 3
MyCell = New TableCell
MyCell.CssClass = dr("CELL3_CSS").ToString
MyCell.Text = dr("CELL3_TEXT").ToString
MyRow.Cells.Add(MyCell)
tblReporting.Rows.Add(MyRow)
End
While
MyCell.Dispose()
MyRow.Dispose()
EndSub
La construction du fichier Excel :
Public
Function ExcelFromTable(ByRef tblTable As Table, ByVal strFilePath AsString) As
Boolean
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlRange As Excel.Range
Dim shExcelProc As
Short
Dim Row As TableRow
Dim iRow As
Integer
Dim iColSpan As
Integer
Dim Cell As TableCell
shExcelProc = ExcelStart(xlApp, False)
xlBook = xlApp.Workbooks.Add()
xlSheet = xlBook.Worksheets.Item(1)
iRow = 1
For
Each Row In tblTable.Rows
xlRange = xlSheet.Range("A" & iRow)
'traitement des celulles
ForEach Cell In Row.Cells
If Cell.ColumnSpan > 1
Then
For iColSpan = 1 To Cell.ColumnSpan
xlRange = xlSheet.Range(xlRange, xlRange.Next)
Next iColSpan
xlRange.MergeCells =
True
End
If
'ici Cell.Style me renvoie Nothing mais Cell.CssClass me renvoie bien le nom du style appliqué, j'aimerai donc récupérer les
'propriétés de ce style dans la feuille de style CSS dont je connais l'URL
xlRange = xlRange.Next
Next Cell
iRow += 1
Next Row
xlBook.SaveAs(strFilePath)
xlSheet =
Nothing
xlBook.Close()
xlBook = Nothing
ExcelQuit(shExcelProc)
xlApp = Nothing
End
Function
Quelqu'un aurait-t-il une idée ?
Rom1