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); Function TOfficeObj(n);
Begin Begin
case lowercase(n) of case lowercase(n) of
@ -14058,7 +14058,7 @@ Type TDocumentBody = Class(DocObject)
if numId = '' then if numId = '' then
begin begin
id := o.Value('BasedOn'); id := o.Value('BasedOn');
return getNumIdByStyle(docx, docx.StyleObject().GetStyleById(id)); return getFieldByStyle(field, docx, docx.StyleObject().GetStyleById(id));
end end
return numId; return numId;
End; End;

View File

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

View File

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

View File

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

View File

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