Hier ist der VB Code daf�r:
Private Sub OpenSpreadsheet()
' Make Excel the Main Window Visible
ExcelApp.Visible = True
Dim missing As Object = System.Reflection.Missing.Value
' Add a Worksheet to Excel
Dim theWorkbook As Excel.Workbook =
ExcelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet)
TheSheet = CType(theWorkbook.Worksheets(1), Excel.Worksheet)
' Get the first row of cells to populate the header
Excel.Range theRange = TheSheet.Cells.get_Range(GetExcelIndexToLetter(0)
+ "1", GetExcelIndexToLetter(NumberOfColumns - 1) + "1")
GetExcelIndexToLetter(NumberOfColumns - 1) + "1")
' draw the column headers in the excel spreadsheet from the GridView
Dim i As Integer
For i = 0 To Me.NumberOfColumns- 1 Step i + 1
' Copy the text of the GridView Header into the Excel Cell
(CType(theRange("1", GetExcelIndexToLetter(i)), Excel.Range)).Value =
listView1.Columns(i).Text
' Set the width of the column in the Excel Spreadsheet to the Width of the GridView
column
(CType(theRange("1", GetExcelIndexToLetter(i)), Excel.Range)).ColumnWidth =
listView1.Columns(i).Width/listView1.Font.SizeInPoints
' Set the Excel Cell To Bold Font
(CType(theRange("1", GetExcelIndexToLetter(i)), Excel.Range)).Font.Bold = True
Next
End Sub
Private Sub WriteExcelData()
Try
Dim i As Integer
For i = 1 To Me.NumberOfRows- 1 Step i + 1
Dim j As Integer
For j = 0 To Me.NumberOfColumns- 1 Step j + 1
' Get the current cell in Excel
Excel.Range theRange = TheSheet.Cells.get_Range(GetExcelIndexToLetter(j)
+ (i + 1).ToString(),
GetExcelIndexToLetter(j) + (i + 1).ToString())
' Copy the GridView cell's Text Value, background color and text color
into the Excel Cell
theRange.Value = GetCell(i, j+1)
theRange.Interior.Color = Me.GetCellColor(i, j+1).ToArgb()
theRange.Font.Color = Me.GetCellTextColor (i, j+1).ToArgb()
' Redraw the cell borders, they seem to disappear after coloring in the
cell
theRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous
theRange.Borders.Color = Color.LightGray.ToArgb()
Next
Next
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
End Try
End Sub
Wegen den Zeilenumbr�chen must gucken, kann sein das die wegen der Mail
falsch gebrochen werden!
Gr��e
Rene
_______________________________________________
Asp.net mailing list
[EMAIL PROTECTED]
http://www.glengamoi.com/mailman/listinfo/asp.net