35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
Function _WordCopyFromExcel(excelFileName, excelSheetName, startRow, startCol, endRow, endCol);
|
|
Begin
|
|
excel := new TSExcelFile();
|
|
[err, msg] := excel.OpenFile('', excelFileName);
|
|
if err then return false;
|
|
total_row := excel.TotalRows(excelSheetName);
|
|
total_col := excel.TotalCols(excelSheetName);
|
|
if not total_row or not total_col then return false;
|
|
if ifnil(startRow) then
|
|
startRow := 1;
|
|
if ifnil(startCol) then
|
|
startCol := 1;
|
|
if ifnil(endRow) then
|
|
endRow := total_row;
|
|
if ifnil(endCol) then
|
|
endCol := total_col;
|
|
data := excel.GetTable(excelSheetName,
|
|
CoordinatesToCellName(startCol, startRow),
|
|
CoordinatesToCellName(endCol, endRow),
|
|
false,
|
|
false,
|
|
false);
|
|
if length(data) = 0 then return false;
|
|
//println('data={}',data);
|
|
docx := TOfficeApi().GetDocument();
|
|
tbl := docx.CreateTable(data, false, false);
|
|
tbl.Format.Borders.Top.Val := 'dashed';
|
|
tbl.Format.Borders.Left.Val := 'dashed';
|
|
tbl.Format.Borders.Bottom.Val := 'dashed';
|
|
tbl.Format.Borders.Right.Val := 'dashed';
|
|
tbl.Format.Borders.InsideH.Val := 'dashed';
|
|
tbl.Format.Borders.InsideV.Val := 'dashed';
|
|
tbl := docx.InsertTable(tbl, TOfficeApi().GetCurrentPosition());
|
|
End;
|