This commit is contained in:
csh 2024-04-12 14:14:47 +08:00
parent 893a3a928b
commit 53d83f91ae
5 changed files with 24 additions and 10 deletions

View File

@ -1,4 +1,4 @@
// Version 1.6.7
// Version 1.6.8
Function TOfficeObj(n);
Begin
case lowercase(n) of
@ -14058,7 +14058,7 @@ Type TDocumentBody = Class(DocObject)
if numId = '' then
begin
id := o.Value('BasedOn');
return getNumIdByStyle(docx, docx.StyleObject().GetStyleById(id));
return getFieldByStyle(field, docx, docx.StyleObject().GetStyleById(id));
end
return numId;
End;

View File

@ -1,4 +1,4 @@
// Version 1.6.7
// Version 1.6.8
Type TSDocxFile = Class
///Version: V1.0 2022-09-20
///适用于 Microsoft Word docx格式文件

View File

@ -1,4 +1,4 @@
// Version 1.6.7
// Version 1.6.8
Type TSXlsxFile = Class
///Version: V1.0 2022-08-08
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。
@ -221,6 +221,8 @@ Type TSXlsxFile = Class
sheet_name := class(TSXml).CurCodePageToUtf8(sheet);
value := class(TSXml).CurCodePageToUtf8(val);
// 处理cell设定的样式
if not ifarray(opt) then opt := array();
workbook_.SetCellStyleOpt(sheet, axis, opt);
SetCellType(sheet, axis, value, opt);
return workbook_.SetCellValue(sheet_name, axis, value, opt);
End;
@ -1004,9 +1006,8 @@ private
Function SetCellType(sheet, axis, val, opt);
Begin
if not ifarray(opt) then opt := array();
if not ifnil(opt['t']) then return;
styleid := GetCellStyle(sheet, axis);
styleid := opt['s'] ? opt['s'] : GetCellStyle(sheet, axis);
[t, val] := style_.GetType(styleid, val);
if t then opt['t'] := t;
End;

View File

@ -106,11 +106,19 @@ Type xlsxWorkBook = Class
End;
Function SetCellValue(sheet, axis, val, opt);
Begin
o := GetSheetObj(sheet);
if ifObj(o) then
ret := o.SetCellValue(axis, val, opt);
return ret;
End;
Function SetCellStyleOpt(sheet, axis, opt);
Begin
o := GetSheetObj(sheet);
if ifObj(o) then
begin
if (ifnil(opt) or ifnil(opt['s'])) and not o.CellIsExists(axis) then
if ifnil(opt['s']) and not o.CellIsExists(axis) then
begin
[err, col, row] := CellNameToCoordinates(axis);
xml := GetSheetXmlFile(sheet);
@ -125,7 +133,6 @@ Type xlsxWorkBook = Class
style := col_node.GetAttribute('style');
if col >= min and col <= max and style <> '' then
begin
if not istable(opt) then opt := array();
opt['s'] := style;
break;
end
@ -133,9 +140,7 @@ Type xlsxWorkBook = Class
end
end
end
ret := o.SetCellValue(axis, val, opt);
end
return ret;
End;
Function GetCellRichText(sheet, axis);

View File

@ -1,5 +1,13 @@
# 更新日志
## 2023-4-12
### V1.6.8
### excel
1. 修复`SetCellValue`单元格对列样式的识别,不需要手动用格式刷对所有单元格刷新样式
## 2023-3-21
### V1.6.7