我查阅了较多的资料,利用DElphi控制Excel,每行每列的控制都没问题了,但是一个复杂的表头我始终想不出来该怎么控制。比如说在Excel中第一行显示一个标题:XXX—xxx学年度XXX考试统计表,然后是正式表,语文涵盖下一行的两个子标题:客观题,主观题,现在的问题是大标题应该放在哪一个单元格,语文放在哪一个单元格才能看起来正好盖住客观题和主观题两个子标题呢?我希望大家明白我的意思。谢谢。
调试欢乐多
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Caption := '学生成绩报表打印';
ExcelApp.WorkBooks.Add;
ExcelApp.WorkSheets[1].Activate;
ExcelApp.Visible := True;
ExcelApp.ActiveWindow.Zoom := 75;
chexingshu:=5+ADOQuery2.RecordCount;
excelx1:=excelop(chexingshu)+'1';
excelx2:='a1';
ExcelApp.Range[excelx2, excelx1].Merge(xl);
ExcelApp.Cells[1,1].Value :=Combobox2.text+Combobox3.text+Combobox4.text+'成绩报表';
ExcelApp.cells.Item[1, 1].font.size := 20;
ExcelApp.cells.Item[1, 1].RowHeight := 25;
ExcelApp.cells.Item[1 , 1].Font.Bold := True;
ExcelApp.cells.Item[1, 1].HorizontalAlignment := xlCenter;
ExcelApp.cells.Item[1, 1].font.Name := '隶书';
ExcelApp.cells.Item[2, 1].HorizontalAlignment := xlCenter;
ExcelApp.cells.Item[2 , 1].Font.Bold := True;
ExcelApp.Cells[2,1].Value :='年级';
ExcelApp.cells.Item[2, 2].HorizontalAlignment := xlCenter;
ExcelApp.cells.Item[2 , 2].Font.Bold := True;
ExcelApp.Cells[2,2].Value :='班级';
ExcelApp.cells.Item[2, 3].HorizontalAlignment := xlCenter;
ExcelApp.cells.Item[2 , 3].Font.Bold := True;
ExcelApp.Cells[2,3].Value :='学期';
ExcelApp.cells.Item[2, 4].HorizontalAlignment := xlCenter;
ExcelApp.cells.Item[2 , 4].Font.Bold := True;
ExcelApp.Cells[2,4].Value :='姓名';
ExcelApp.cells.Item[2, 5].HorizontalAlignment := xlCenter;
ExcelApp.cells.Item[2 , 5].Font.Bold := True;
ExcelApp.Cells[2,5].Value :='学号';
chexingshu:=5+ADOQuery2.RecordCount;
excelx1:=excelop(chexingshu)+'1';
excelx2:='a1';
ExcelApp.Range[excelx2, excelx1].Merge(xl);
ExcelApp.Cells[1,1].Value :=Combobox2.text+Combobox3.text+Combobox4.text+'成绩报表';