只读取200行
#include <Excel.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Const $xlColumns = 2
Const $xl3DPieExploded = 70
Const $xlDataLabelsShowValue = 2
TrayTip("小苹果提示", "窗口程序正在加载数据,请等待...", 3, 1)
$begin = TimerInit()
Local $oExcel = ObjCreate("Excel.Application") ; 创建Excel对象
$oExcel.Visible = 1
$oExcel.SheetsInNewWorkbook = 1 ; 设置要创建的工作表数量
; 或打开现有文件:
$cInput = "list.csv"
Local $sFilePath = @ScriptDir & '\' & $cInput ;& '.xlsx';@ScriptDir & "\Book3.xlsx";
Local $oBook = $oExcel.WorkBooks.Open($sFilePath, Default, False)
Local $oSheet = $oBook.Worksheets.Item(1) ; 工作表的名称
Local $r = 2
For $i = 0 To 201
If $i = 201 Then
$oSheet.Range("j2").Offset($i, 0).Formula = "=SUM(j2:j201)"
Else
$oSheet.Range("j2").Offset($i, 0).Formula = "=SUM(B" & $r & ":I" & $r & ")"
$r += 1
EndIf
Next
Local $width = 500, $height = 450
; 右对齐单元格I13:
Local $left = $oSheet.Range("J49015").Left - $width ; Cell J13:left = cell I13:right!
Local $top = $oSheet.Range("I49015").Top
; 创建一个对象图
Local $oChart = $oSheet.ChartObjects.Add($left, $top, $width, $height).Chart
With $oChart
.ChartType = $xl3DPieExploded ; 设置图表类型
.SetSourceData($oSheet.Range("j2:j99"), $xlColumns) ; 图表的数据区域
.SeriesCollection(1).XValues = "='Sheet1'!j2S1:j201S1" ; 标签图例集(名称来自A2:A10)
.HasTitle = True ;激活标题
.ChartTitle.Characters.Text = "总数200行 (合计 = " & StringFormat('%.2f', $oSheet.Range('j203').Value) & ")" ; 标题
.ApplyDataLabels($xlDataLabelsShowValue, False, True) ; 细分标注值
EndWith
_Excel_BookClose($oExcel, False)
$dif = TimerDiff($begin) / 1000
MsgBox(0, "导出速度", '读取' & ' 用时' & Int($dif) & '秒', 2)
TrayTip("", "", 1, 0)
|