diff --git a/funcext/TSOffice/TOfficeObj.tsf b/funcext/TSOffice/TOfficeObj.tsf index 34ec22a..3753e76 100644 --- a/funcext/TSOffice/TOfficeObj.tsf +++ b/funcext/TSOffice/TOfficeObj.tsf @@ -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; diff --git a/funcext/TSOffice/TSDocxFile.tsf b/funcext/TSOffice/TSDocxFile.tsf index bf3ec3d..3029f49 100644 --- a/funcext/TSOffice/TSDocxFile.tsf +++ b/funcext/TSOffice/TSDocxFile.tsf @@ -1,4 +1,4 @@ -// Version 1.6.7 +// Version 1.6.8 Type TSDocxFile = Class ///Version: V1.0 2022-09-20 ///适用于 Microsoft Word docx格式文件 diff --git a/funcext/TSOffice/TSXlsxFile.tsf b/funcext/TSOffice/TSXlsxFile.tsf index aae904b..0411a24 100644 --- a/funcext/TSOffice/TSXlsxFile.tsf +++ b/funcext/TSOffice/TSXlsxFile.tsf @@ -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; diff --git a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf index 1e36bf7..ed0fec6 100644 --- a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf +++ b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf @@ -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); diff --git a/更新日志.md b/更新日志.md index 49c4bb7..8fea07c 100644 --- a/更新日志.md +++ b/更新日志.md @@ -1,5 +1,13 @@ # 更新日志 +## 2023-4-12 + +### V1.6.8 + +### excel + +1. 修复`SetCellValue`单元格对列样式的识别,不需要手动用格式刷对所有单元格刷新样式 + ## 2023-3-21 ### V1.6.7