Advertisement
Advertisement
| 07.23.2008 at 12:45AM PDT, ID: 23587621 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: |
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Open(FileToLoad)
ws = wb.Sheets("Sheet1")
excel.Visible = True
wb.Activate()
Try
Dim xlRange As Excel.Range = DirectCast(ws, Excel.Worksheet).Range("1:65536")
'Create the Pivotcache.
Dim ptCache As Excel.PivotCache = wb.PivotCaches.Add(SourceType:=excel.XlPivotTableSourceType.xlExternal)
'Create the Pivottable.
Dim ptTable As Excel.PivotTable = ws.PivotTables.Add(PivotCache:=ptCache, _
TableDestination:=xlRange, TableName:="PT_Report")
'Setup the Pivottable.
With ptTable
.ManualUpdate = True
.PivotFields("POS").Orientation = excel.XlPivotFieldOrientation.xlRowField
.PivotFields("SKU").Orientation = excel.XlPivotFieldOrientation.xlDataField()
.PivotFields("LINE_OVERALL_DISCOUNT").Orientation = excel.XlPivotFieldOrientation.xlDataField()
.Format(excel.XlPivotFormatType.xlReport2)
.ManualUpdate = False
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
|