Created
April 14, 2010 01:38
-
-
Save taka2/365349 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Imports System | |
| Class VBNETTest | |
| Public Shared Sub Main() | |
| Console.WriteLine(DateTime.Now) | |
| Dim excelObj | |
| Dim numrows As Integer = 10000 | |
| Dim numcols As Integer = 100 | |
| Dim arr1 As Object | |
| ReDim arr1(numrows, numcols) | |
| Dim i, j As Integer | |
| For i = 0 to numrows - 1 | |
| For j = 0 to numcols - 1 | |
| arr1(i, j) = i * j | |
| Next | |
| Next | |
| Try | |
| ' Excelを起動する | |
| excelObj = New Excel.Application | |
| Dim workbooksObj, newWorkbook, worksheet | |
| workbooksObj = excelObj.Workbooks | |
| newWorkbook = workbooksObj.Add | |
| worksheet = newWorkbook.Sheets(1) | |
| worksheet.Range(worksheet.Cells(1, 1), worksheet.Cells(numrows, numcols)).Value = arr1 | |
| ' 保存 | |
| newWorkbook.SaveAs("filename.xls") | |
| Catch ex As Exception | |
| Console.WriteLine(ex) | |
| Finally | |
| ' Excelを終了する | |
| excelObj.Quit() | |
| System.Runtime.InteropServices.Marshal.ReleaseComObject(excelObj) | |
| excelObj = Nothing | |
| End Try | |
| Console.WriteLine(DateTime.Now) | |
| End Sub | |
| End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment