REM -----------------------------------------------
REM --- 定义Excel变量,以便打开Excel -------
REM -----------------------------------------------
Set xlApp = CreateObject("Excel.Application"
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
REM ------------------------------------------------
REM --- 缺省将报表标题传递给Excel -------
REM ------------------------------------------------
Row=2
Index=(Rpt.FieldCount)/2
xlSheet.Cells(Row,Index).Value="变电站母线不平衡率"
REM ------------------------------------------------
REM --- 设置标题和字段的字体属性 -------
REM ------------------------------------------------
xlSheet.Rows(2).Font.Name="宋体"
xlSheet.Rows(2).Font.color=clred
xlSheet.Rows(2).Font.bold=true
xlSheet.Rows(2).Font.size=16
xlSheet.Rows(4).Font.Name="宋体"
xlSheet.Rows(4).Font.color=clblue
xlSheet.Rows(4).Font.bold=true
xlSheet.Rows(4).Font.size=12
REM ------------------------------------------------
REM --- 设置各个列的宽度 -------
REM ------------------------------------------------
xlSheet.Columns(1).ColumnWidth=15
xlSheet.Columns(2).ColumnWidth=15
xlSheet.Columns(3).ColumnWidth=15
xlSheet.Columns(4).ColumnWidth=15
xlSheet.Columns(5).ColumnWidth=15
xlSheet.Columns(6).ColumnWidth=15
xlSheet.Columns(7).ColumnWidth=16
xlSheet.Columns(8).ColumnWidth=15
xlSheet.Columns(9).ColumnWidth=15
xlSheet.Columns(10).ColumnWidth=28
REM ------------------------------------------------
REM --- 缺省将所有字段标题传递给Excel -------
REM ------------------------------------------------
Row=4
Index=1
for I=1 to Rpt.FieldCount
xlSheet.Cells(Row,Index).Value=Rpt.FieldTitleByIndex(Index-1)
Index=Index+1
NEXT
REM ------------------------------------------------
REM --- 缺省将所有字段传递给Excel -------
REM ------------------------------------------------
Row=5
Index=1
Rpt.GotoFirst
DO while not (Rpt.EOF = True)
Index=1
for I=1 to Rpt.FieldCount
xlSheet.Cells(Row,Index).Value=Rpt.FieldByIndex(Index-1)
Index=Index+1
NEXT
Row=Row+1
Rpt.GotoNext
LOOP
REM ------------------------------------------------
REM --- 设置打印单元格网线 -------
REM ------------------------------------------------
xlsheet.PageSetup.PrintGridLines=True
REM ------------------------------------------------
REM --- 缺省将报表标题传递给Excel -------
REM ------------------------------------------------
xlapp.caption="变电站母线不平衡率"
REM ------------------------------------------------
REM --- 打开Excel的显示 -------------
REM ------------------------------------------------
xlApp.Visible=True
以上是我的excel脚本,不知道错误的原因出在哪里?你帮忙看看,谢了。