|
分類:[VB.NET/VB2005 以降]
VB6.0では、下記のようにコーディングされています
Private Const xlEdgeTop = 8 Private Const xlEdgeBottom = 9 Private Const xlContinuous = 1 Private Const xlThin = 2 Private Const xlAutomatic = -4105 : : Public Function excel() As Boolean Dim xlsApp As Object Dim xlsbook As Object Dim xlssheet As Object Dim xlssheetCopy As Object : :
xlssheet.Cells(2, 2) = "ABC"
'明細部コピー(書式&罫線コピー) xlssheet.Range(xlssheet.Cells(2, 2), xlssheet.Cells(2, 12)).Copy xlssheet.Range(xlssheet.Cells(2, 2), xlssheet.Cells(10, 12)).Select xlssheet.Paste
xlssheet.Cells(3, 2) = "あいうえお"
'罫線 xlssheet.Cells(3, 2).Borders(xlEdgeTop).LineStyle = xlContinuous xlssheet.Cells(3, 2).Borders(xlEdgeTop).Weight = xlThin xlssheet.Cells(3, 2).Borders(xlEdgeTop).ColorIndex = xlAutomatic : :
とあります。 これを、.Netで焼き直しを行っていますが、セルに値を入れることはできましたが コピーや罫線を引くところが解りません 一応下記のようにコーディングしてみました
Private Const xlEdgeTop = 8 Private Const xlEdgeBottom = 9 Private Const xlContinuous = 1 Private Const xlThin = 2 Private Const xlAutomatic = -4105 : : Public Function excel() As Boolean
Dim xlApp As Excel.Application = Nothing Dim xlBooks As Excel.Workbooks = Nothing Dim xlBook As Excel.Workbook = Nothing Dim xlSheets As Excel.Sheets = Nothing Dim xlSheet1 As Excel.Worksheet = Nothing Dim xlRange As Excel.Range = Nothing Dim xlCells As Excel.Range = Nothing : :
xlRange = xlCells(2, 2) xlRange.Value = "ABC" System.Runtime.InteropServices.Marshal.ReleaseComObject(xlRange)
'明細部コピー(書式&罫線コピー) この部分がわかりません
xlRange = xlCells(3, 2) xlRange.Value = "あいうえお" System.Runtime.InteropServices.Marshal.ReleaseComObject(xlRange)
'罫線 この部分がわかりません
お解りの方よろしくお願いします
|