整理word内容作为unit
This commit is contained in:
parent
3643be6231
commit
15e2cbe661
|
|
@ -0,0 +1,297 @@
|
||||||
|
Unit TSWordTemplateMethods;
|
||||||
|
Interface
|
||||||
|
Function ExcelChartCopyPic(excelFileName, excelSheetName, chartName, width, height);
|
||||||
|
Function WordAddOleObjectFromFile(fileName, width, height);
|
||||||
|
Function WordBr();
|
||||||
|
Function WordCopyFromExcel(excelFileName, excelSheetName, startRow, startCol, endRow, endCol);
|
||||||
|
Function WordGetCurrentDocument();
|
||||||
|
Function WordGetCurrentRange();
|
||||||
|
Function WordGetFont(prop, value);
|
||||||
|
Function WordGetLastRange();
|
||||||
|
Function WordGetLastShape();
|
||||||
|
Function WordGetLastTable();
|
||||||
|
Function WordGetLastTableCellProp(row, col, name, value);
|
||||||
|
Function WordGetLastTableProp(name, value);
|
||||||
|
Function WordLastTableMerge(row1, col1, row2, col2);
|
||||||
|
Function WordSetCurrentRange(range);
|
||||||
|
Function WordSetFont(prop, value);
|
||||||
|
Function WordSetLastTableCellProp(row, col, name, value);
|
||||||
|
Function WordSetLastTableProp(name, value);
|
||||||
|
Function WordSetRangeProp(name, value);
|
||||||
|
Function WordTemplate(data, template, fileName);
|
||||||
|
Function WordWrite();
|
||||||
|
Function WordWritePicFromFile(fileName);
|
||||||
|
Function WordWriteTable(table, writeIntIndex, writeIntTitle, incIntIndex);
|
||||||
|
|
||||||
|
Implementation
|
||||||
|
Function ExcelChartCopyPic(excelFileName, excelSheetName, chartName, width, height);
|
||||||
|
Begin
|
||||||
|
docx := TOfficeApi().GetDocument();
|
||||||
|
chart := docx.CopyExcelChart(excelFileName, excelSheetName, chartName, width, height, TOfficeApi().GetCurrentPosition());
|
||||||
|
return ifObj(chart);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordBr();
|
||||||
|
Begin
|
||||||
|
TOfficeApi().GetDocument().AddLineBreak(TOfficeApi().Get('CurrentPosition'));
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordCopyFromExcel(excelFileName, excelSheetName, startRow, startCol, endRow, endCol);
|
||||||
|
Begin
|
||||||
|
excel := new TSXlsFile();
|
||||||
|
[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;
|
||||||
|
|
||||||
|
Function WordGetCurrentDocument();
|
||||||
|
Begin
|
||||||
|
return TOfficeApi().GetDocument();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordGetCurrentRange();
|
||||||
|
Begin
|
||||||
|
return TOfficeApi().GetCurrentPosition();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordGetFont(prop, value);
|
||||||
|
Begin
|
||||||
|
crun := TOfficeApi().GetCurrentRun();
|
||||||
|
node := crun.Node().FirstChildElement('w:rPr');
|
||||||
|
rPr := TOfficeObj('TwrPr');
|
||||||
|
rPr.InitRootNode(node);
|
||||||
|
value := rPr.Value(prop);
|
||||||
|
if not ifnil(value) then return true;
|
||||||
|
return false;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordGetLastShape();
|
||||||
|
Begin
|
||||||
|
node := TOfficeApi().Get('CurrentShape');
|
||||||
|
if not ifObj(node) then return nil;
|
||||||
|
uri := 'w:r/w:drawing/wp:inline/a:graphic/a:graphicData/c:chart';
|
||||||
|
cNode := class(TSXml).GetNode(node, uri);
|
||||||
|
if ifObj(cNode) then Begin
|
||||||
|
chart := TOfficeObj('TChart');
|
||||||
|
chart.Init(TOfficeApi().GetDocument(), node, cNode);
|
||||||
|
return chart;
|
||||||
|
End;
|
||||||
|
|
||||||
|
pic := TOfficeObj('TPicture');
|
||||||
|
pic.Init(node);
|
||||||
|
return pic;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordGetLastRange();
|
||||||
|
Begin
|
||||||
|
return TOfficeApi().GetCurrentPosition();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordGetLastTable();
|
||||||
|
Begin
|
||||||
|
return TOfficeApi().Get('CurrentTable');
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordGetLastTableCellProp(row, col, name, value);
|
||||||
|
Begin
|
||||||
|
table_node := TOfficeApi().Get('CurrentTable');
|
||||||
|
if ifnil(table_node) then return false;
|
||||||
|
table := TOfficeObj("TTable");
|
||||||
|
table.Init(table_node);
|
||||||
|
table_cell := table.Cell(row, col);
|
||||||
|
ctr := _wordCompTable();
|
||||||
|
name_ := ctr[lowercase(name)];
|
||||||
|
if ifnil(name_) then name_ := name;
|
||||||
|
str := 'return table_cell.Format.' $ name_ $ '"' $ value $ '"';
|
||||||
|
value := eval(&str);
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordGetLastTableProp(name, value);
|
||||||
|
Begin
|
||||||
|
table_node := TOfficeApi().Get('CurrentTable');
|
||||||
|
if ifnil(table_node) then return false;
|
||||||
|
table := TOfficeObj("TTable");
|
||||||
|
table.Init(table_node);
|
||||||
|
ctr := _wordCompTable();
|
||||||
|
name_ := ctr[lowercase(name)];
|
||||||
|
if ifnil(name_) then name_ := name;
|
||||||
|
str := 'return table.Format.' $ name_ $ '"' $ value $ '"';
|
||||||
|
value := eval(&str);
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordLastTableMerge(row1, col1, row2, col2);
|
||||||
|
Begin
|
||||||
|
table_node := TOfficeApi().Get('CurrentTable');
|
||||||
|
if ifnil(table_node) then return false;
|
||||||
|
table := TOfficeObj("TTable");
|
||||||
|
table.Init(table_node);
|
||||||
|
[err1, beg_cell] := CoordinatesToCellName(col1, row1);
|
||||||
|
[err2, end_cell] := CoordinatesToCellName(col2, row2);
|
||||||
|
if err1 or err2 then return false;
|
||||||
|
table.Merge(beg_cell, end_cell, false);
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordSetCurrentRange(range);
|
||||||
|
Begin
|
||||||
|
TOfficeApi().Set('CurrentPosition', range);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordSetFont(prop, value);
|
||||||
|
Begin
|
||||||
|
run := TOfficeApi().GetCurrentRun();
|
||||||
|
str := 'run.font.' $ prop $ ' := ' $ '"' $ value $ '"';
|
||||||
|
eval(&str);
|
||||||
|
run.Apply();
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordSetLastTableCellProp(row, col, name, value);
|
||||||
|
Begin
|
||||||
|
table := TOfficeApi().Get('CurrentTable');
|
||||||
|
if ifnil(table) then return false;
|
||||||
|
table_cell := table.Cell(row, col);
|
||||||
|
ctr := _wordCompTable();
|
||||||
|
name_ := ctr[lowercase(name)];
|
||||||
|
if ifnil(name_) then name_ := name;
|
||||||
|
str := 'table_cell.Format.' $ name_ $ ' := ';
|
||||||
|
if ifstring(value) then
|
||||||
|
str += '"' $ value $ '"';
|
||||||
|
else
|
||||||
|
str := str $ value;
|
||||||
|
eval(&str);
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordSetLastTableProp(name, value);
|
||||||
|
Begin
|
||||||
|
table := TOfficeApi().Get('CurrentTable');
|
||||||
|
if ifnil(table) then return false;
|
||||||
|
ctr := _wordCompTable();
|
||||||
|
name_ := ctr[lowercase(name)];
|
||||||
|
if ifnil(name_) then name_ := name;
|
||||||
|
str := 'table.Format.' $ name_ $ ' := ';
|
||||||
|
if ifstring(value) then
|
||||||
|
str += '"' $ value $ '"';
|
||||||
|
else
|
||||||
|
str := str $ value;
|
||||||
|
eval(&str);
|
||||||
|
TOfficeApi().Set('CurrentTable', table);
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordSetRangeProp(name, value);
|
||||||
|
Begin
|
||||||
|
cur := TOfficeApi().GetCurrentPosition();
|
||||||
|
if ifnil(cur) then return nil;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordTemplate(data, template, fileName);
|
||||||
|
Begin
|
||||||
|
setsysparam('data', data);
|
||||||
|
docx := new TSDocxFile();
|
||||||
|
[err, msg] := docx.OpenFile('', template);
|
||||||
|
if err then return false;
|
||||||
|
docx.ExecInnerTSL();
|
||||||
|
if ifstring(fileName) then
|
||||||
|
begin
|
||||||
|
[err, msg] := docx.SaveAs('', fileName);
|
||||||
|
if err then return false;
|
||||||
|
end
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordWrite();
|
||||||
|
Begin
|
||||||
|
docx := TOfficeApi().GetDocument();
|
||||||
|
curParagraph := TOfficeApi().GetCurrentParagraph();
|
||||||
|
curRun := TOfficeApi().GetCurrentRun();
|
||||||
|
for i:=1 to PARAMCOUNT do Begin
|
||||||
|
argv := params[i];
|
||||||
|
if ifstring( argv ) then
|
||||||
|
curRun.AddText( argv );
|
||||||
|
else if ifnumber(argv) then
|
||||||
|
curRun.AddText('' $ argv);
|
||||||
|
else if ifarray(argv) then Begin
|
||||||
|
tbl := docx.CreateTable(argv, false, false);
|
||||||
|
tbl := docx.InsertTable(tbl, TOfficeApi().GetCurrentPosition());
|
||||||
|
End
|
||||||
|
End
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordWritePicFromFile(fileName);
|
||||||
|
Begin
|
||||||
|
file_size := fileSize('', fileName);
|
||||||
|
flag := readfile(rwbinary(), '', fileName, 0, file_size, data);
|
||||||
|
if not flag then return false;
|
||||||
|
picture := TOfficeObj('TPicture');
|
||||||
|
picture.Image := data;
|
||||||
|
docx := TOfficeApi().GetDocument();
|
||||||
|
docx.AddPicture(picture, TOfficeApi().GetCurrentPosition());
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function WordWriteTable(table, writeIntIndex, writeIntTitle, incIntIndex);
|
||||||
|
Begin
|
||||||
|
docx := TOfficeApi().GetDocument();
|
||||||
|
tbl := docx.CreateTable(table, true, writeIntIndex);
|
||||||
|
table := docx.InsertTable(tbl, TOfficeApi().GetCurrentPosition());
|
||||||
|
return true;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function _wordCompTable();
|
||||||
|
Begin
|
||||||
|
return array(
|
||||||
|
'alignment': 'Alignment',
|
||||||
|
'shadingcolor': 'Shading.Color',
|
||||||
|
'style': 'StyleID',
|
||||||
|
'verticalalignment': 'Valign',
|
||||||
|
'width': 'Width',
|
||||||
|
);
|
||||||
|
End;
|
||||||
|
|
||||||
|
// TODO:尚未支持
|
||||||
|
Function WordAddOleObjectFromFile(fileName, width, height);
|
||||||
|
Begin
|
||||||
|
End;
|
||||||
|
Function WordCopyPicFormatExcel(excelFileName, excelSheetName, startRow, startCol, endRow, endCol, picType);
|
||||||
|
Begin
|
||||||
|
End;
|
||||||
|
Function WordGetRangeProp(name, value);
|
||||||
|
Begin
|
||||||
|
End;
|
||||||
|
Function WordLastTableSplit(row, col, rCnt, cCnt);
|
||||||
|
Begin
|
||||||
|
End;
|
||||||
|
|
||||||
|
End.
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
Function _ExcelChartCopyPic(excelFileName, excelSheetName, chartName, Width, Height);
|
|
||||||
Begin
|
|
||||||
docx := TOfficeApi().GetDocument();
|
|
||||||
chart := docx.CopyExcelChart(excelFileName, excelSheetName, chartName, Width, Height, TOfficeApi().GetCurrentPosition());
|
|
||||||
return ifObj(chart);
|
|
||||||
End;
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
Function _WordAddOleObjectFromFile(fileName, width, height);
|
|
||||||
Begin
|
|
||||||
End;
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
Function _WordBr();
|
|
||||||
Begin
|
|
||||||
TOfficeApi().GetDocument().AddLineBreak(TOfficeApi().Get('CurrentPosition'));
|
|
||||||
End;
|
|
||||||
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
Function _WordCopyPicFormatExcel(excelFileName, excelSheetName, startRow, startCol, endRow, endCol, picType);
|
|
||||||
Begin
|
|
||||||
End;
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
Function _WordGetCurrentDocument();
|
|
||||||
Begin
|
|
||||||
return TOfficeApi().GetDocument();
|
|
||||||
End;
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
Function _WordGetCurrentRange();
|
|
||||||
Begin
|
|
||||||
return TOfficeApi().GetCurrentPosition();
|
|
||||||
End;
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
Function _WordGetFont(prop, value);
|
|
||||||
Begin
|
|
||||||
crun := TOfficeApi().GetCurrentRun();
|
|
||||||
node := crun.Node().FirstChildElement('w:rPr');
|
|
||||||
rPr := TOfficeObj('TwrPr');
|
|
||||||
rPr.InitRootNode(node);
|
|
||||||
value := rPr.Value(prop);
|
|
||||||
if not ifnil(value) then return true;
|
|
||||||
return false;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
Function _WordGetLastRange();
|
|
||||||
Begin
|
|
||||||
return TOfficeApi().GetCurrentPosition();
|
|
||||||
End;
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
Function _WordGetLastShape();
|
|
||||||
Begin
|
|
||||||
node := TOfficeApi().Get('CurrentShape');
|
|
||||||
if not ifObj(node) then return nil;
|
|
||||||
uri := 'w:r/w:drawing/wp:inline/a:graphic/a:graphicData/c:chart';
|
|
||||||
cNode := class(TSXml).GetNode(node, uri);
|
|
||||||
if ifObj(cNode) then Begin
|
|
||||||
chart := TOfficeObj('TChart');
|
|
||||||
chart.Init(TOfficeApi().GetDocument(), node, cNode);
|
|
||||||
return chart;
|
|
||||||
End;
|
|
||||||
|
|
||||||
pic := TOfficeObj('TPicture');
|
|
||||||
pic.Init(node);
|
|
||||||
return pic;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
Function _WordGetLastTable();
|
|
||||||
Begin
|
|
||||||
return TOfficeApi().Get('LastTable');
|
|
||||||
End;
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
Function _WordGetLastTableCellProp(row, col, name, value);
|
|
||||||
Begin
|
|
||||||
table := TOfficeApi().Get('LastTable');
|
|
||||||
if ifnil(table) then return false;
|
|
||||||
table_cell := table.Cell(row, col);
|
|
||||||
ctr := _wordCompTable();
|
|
||||||
name_ := ctr[lowercase(name)];
|
|
||||||
if ifnil(name_) then name_ := name;
|
|
||||||
str := 'return table_cell.Format.' $ name_ $ '"' $ value $ '"';
|
|
||||||
value := eval(&str);
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
Function _WordGetLastTableProp(name, value);
|
|
||||||
Begin
|
|
||||||
table := TOfficeApi().Get('LastTable');
|
|
||||||
if ifnil(table) then return false;
|
|
||||||
ctr := _wordCompTable();
|
|
||||||
name_ := ctr[lowercase(name)];
|
|
||||||
if ifnil(name_) then name_ := name;
|
|
||||||
str := 'return table.Format.' $ name_ $ '"' $ value $ '"';
|
|
||||||
value := eval(&str);
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
Function _WordGetRangeProp(name, value);
|
|
||||||
Begin
|
|
||||||
End;
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
Function _WordLastTableMerge(row1, col1, row2, col2);
|
|
||||||
Begin
|
|
||||||
table := TOfficeApi().Get('LastTable');
|
|
||||||
if ifnil(table) then return false;
|
|
||||||
[err1, beg_cell] := CoordinatesToCellName(col1, row1);
|
|
||||||
[err2, end_cell] := CoordinatesToCellName(col2, row2);
|
|
||||||
if err1 or err2 then return false;
|
|
||||||
table.Merge(beg_cell, end_cell, false);
|
|
||||||
TOfficeApi().Set('LastTable', table);
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
Function _WordLastTableSplit(row, col, rCnt, cCnt);
|
|
||||||
Begin
|
|
||||||
End;
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
Function _WordSetCurrentRange(range);
|
|
||||||
Begin
|
|
||||||
TOfficeApi().Set('CurrentPosition', range);
|
|
||||||
End;
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
Function _WordSetCurrnetRange(range);
|
|
||||||
Begin
|
|
||||||
TOfficeApi().Set('CurrentPosition', range);
|
|
||||||
End;
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
Function _WordSetFont(prop, value);
|
|
||||||
Begin
|
|
||||||
run := TOfficeApi().GetCurrentRun();
|
|
||||||
str := 'run.font.' $ prop $ ' := ' $ '"' $ value $ '"';
|
|
||||||
eval(&str);
|
|
||||||
run.Apply();
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
Function _WordSetLastTableCellProp(row, col, name, value);
|
|
||||||
Begin
|
|
||||||
table := TOfficeApi().Get('LastTable');
|
|
||||||
if ifnil(table) then return false;
|
|
||||||
table_cell := table.Cell(row, col);
|
|
||||||
ctr := _wordCompTable();
|
|
||||||
name_ := ctr[lowercase(name)];
|
|
||||||
if ifnil(name_) then name_ := name;
|
|
||||||
str := 'table_cell.Format.' $ name_ $ ' := ';
|
|
||||||
if ifstring(value) then
|
|
||||||
str += '"' $ value $ '"';
|
|
||||||
else
|
|
||||||
str = str $ value;
|
|
||||||
eval(&str);
|
|
||||||
TOfficeApi().Set('LastTable', table);
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
Function _WordSetLastTableProp(name, value);
|
|
||||||
Begin
|
|
||||||
table := TOfficeApi().Get('LastTable');
|
|
||||||
if ifnil(table) then return false;
|
|
||||||
ctr := _wordCompTable();
|
|
||||||
name_ := ctr[lowercase(name)];
|
|
||||||
if ifnil(name_) then name_ := name;
|
|
||||||
str := 'table.Format.' $ name_ $ ' := ';
|
|
||||||
if ifstring(value) then
|
|
||||||
str += '"' $ value $ '"';
|
|
||||||
else
|
|
||||||
str = str $ value;
|
|
||||||
eval(&str);
|
|
||||||
TOfficeApi().Set('LastTable', table);
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
Function _WordSetRangeProp(name, value);
|
|
||||||
Begin
|
|
||||||
cur := TOfficeApi().GetCurrentPosition();
|
|
||||||
if ifnil(cur) then return nil;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
Function _WordTemplate(data, template, fileName);
|
|
||||||
Begin
|
|
||||||
setsysparam('data', data);
|
|
||||||
docx := new TSDocxFile();
|
|
||||||
[err, msg] := docx.OpenFile('', template);
|
|
||||||
if err then return false;
|
|
||||||
docx.ExecInnerTSL();
|
|
||||||
if ifstring(fileName) then
|
|
||||||
begin
|
|
||||||
[err, msg] := docx.SaveAs('', fileName);
|
|
||||||
if err then return false;
|
|
||||||
end
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
Function _WordWrite();
|
|
||||||
Begin
|
|
||||||
docx := TOfficeApi().GetDocument();
|
|
||||||
curParagraph := TOfficeApi().GetCurrentParagraph();
|
|
||||||
curRun := TOfficeApi().GetCurrentRun();
|
|
||||||
for i:=1 to PARAMCOUNT do Begin
|
|
||||||
argv := params[i];
|
|
||||||
if ifstring( argv ) then
|
|
||||||
curRun.AddText( argv );
|
|
||||||
else if ifnumber(argv) then
|
|
||||||
curRun.AddText('' $ argv);
|
|
||||||
else if ifarray(argv) then Begin
|
|
||||||
tbl := docx.CreateTable(argv, false, false);
|
|
||||||
tbl := docx.InsertTable(tbl, TOfficeApi().GetCurrentPosition());
|
|
||||||
End
|
|
||||||
End
|
|
||||||
End;
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
Function _WordWritePicFromFile(fileName);
|
|
||||||
Begin
|
|
||||||
file_size := fileSize('', fileName);
|
|
||||||
flag := readfile(rwbinary(), '', fileName, 0, file_size, data);
|
|
||||||
if not flag then return false;
|
|
||||||
picture := TOfficeObj('TPicture');
|
|
||||||
picture.Image := data;
|
|
||||||
docx := TOfficeApi().GetDocument();
|
|
||||||
docx.AddPicture(picture, TOfficeApi().GetCurrentPosition());
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
Function _WordWriteTable(table, writeIntIndex, writeIntTitle, incIntIndex);
|
|
||||||
Begin
|
|
||||||
docx := TOfficeApi().GetDocument();
|
|
||||||
tbl := docx.CreateTable(table, true, writeIntIndex);
|
|
||||||
table := docx.InsertTable(tbl, TOfficeApi().GetCurrentPosition());
|
|
||||||
TOfficeApi().Set('LastTable', table);
|
|
||||||
return true;
|
|
||||||
End;
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
Function _wordCompTable();
|
|
||||||
Begin
|
|
||||||
return array(
|
|
||||||
'alignment': 'Alignment',
|
|
||||||
'shadingcolor': 'Shading.Color',
|
|
||||||
'style': 'StyleID',
|
|
||||||
'verticalalignment': 'Valign',
|
|
||||||
'width': 'Width',
|
|
||||||
);
|
|
||||||
End;
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
_WordTemplate(alias, fileName);
|
|
||||||
_WordCopyFromExcel(excelFileName, excelSheetName, startRow, startCol, endRow, endCol);
|
|
||||||
_WordCopyPicFromExcel(excelFileName, excelSheetName, startRow, startCol, endRow, endCol, picType);
|
|
||||||
_ExcelChartCopyPic(excelFileName, excelSheetName, picType);
|
|
||||||
_WordGetCurrentDocument();
|
|
||||||
_WordGetCurrentRange();
|
|
||||||
_WordSetCurrnetRange(range);
|
|
||||||
_WordGetLastRange();
|
|
||||||
_WordGetLastTable();
|
|
||||||
_WordGetLastShape();
|
|
||||||
_WordWrite();
|
|
||||||
_WordBr();
|
|
||||||
_WordWriteTable(table, writeIntIndex, writeIntTile, incIntIndex);
|
|
||||||
_WordWritePicFromFile(fileName);
|
|
||||||
_WordSetFont(prop, value);
|
|
||||||
_WordGetFont(prop, value);
|
|
||||||
_WordAddOleObjectFromFile(fileName, width, height);
|
|
||||||
_WordLastTableSplit(row, col, rCnt, cCnt);
|
|
||||||
_WordLastTableMerge(row1, col1, row2, col2);
|
|
||||||
_WordSetRangeProp(name, value);
|
|
||||||
_WordGetRangeProp(name, value);
|
|
||||||
_WordSetLastTableProp(name, value);
|
|
||||||
_WordGetLastTableProp(name, value);
|
|
||||||
_WordSetLastTableCellProp(row, col, name, value);
|
|
||||||
_WordGetLastTableCellProp(row, col, name, value);
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue