Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim excel As New Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim xlapp As New Microsoft.Office.Interop.Excel.Application
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlsheet As Microsoft.Office.Interop.Excel.Worksheet
Dim riga As Integer = 5
Dim righe As Integer = 1
xlBook = xlapp.Workbooks.Open("c:\memo.xlsx")
xlsheet = xlapp.Worksheets("Foglio1")
xlapp.Application.DisplayAlerts = False
xlsheet.Activate()
xlsheet.Delete()
xlsheet = xlBook.Worksheets.Add
xlsheet.Name = ("Foglio1")
xlsheet.Columns("A:A").NumberFormat = "hh:MM:ss;@"
xlsheet.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape
xlapp.Application.DisplayAlerts = True
'xlapp.ActiveSheet.CELLS.EntireColumn.AutoFit()
xlsheet.Cells(righe, 1) = ws.Cells(riga, 3)
xlsheet.Cells(righe, 1).VALUE = ws.Cells(riga, 3).value
xlsheet.Cells(righe, 2).VALUE = ws.Cells(riga, 4).VALUE
xlsheet.Cells(righe, 3).VALUE = ws.Cells(riga, 9).VALUE
xlsheet.Cells(righe, 4).VALUE = ws.Cells(riga, 10).VALUE
xlsheet.Cells(righe, 5).VALUE = ws.Cells(riga, 11).VALUE
xlsheet.Cells(righe, 6).VALUE = ws.Cells(riga, 14).VALUE
xlsheet.Cells(righe, 7).VALUE = ws.Cells(riga, 15).VALUE
xlsheet.Cells(righe, 8).VALUE = ws.Cells(riga, 17).VALUE
xlsheet.Cells(righe, 9).VALUE = ws.Cells(riga, 18).VALUE
xlsheet.Cells(righe, 10).VALUE = ws.Cells(riga, 7).VALUE
riga = riga + 1
Loop
xlBook.Close(True) ' False per non salvare le modifiche
xlapp.Quit()
xlsheet = Nothing
xlBook = Nothing
xlapp = Nothing