From 0f07603d733be1ec1c43e9958e4d4583bcecd2d8 Mon Sep 17 00:00:00 2001 From: csh Date: Wed, 8 Jan 2025 15:31:04 +0800 Subject: [PATCH] v1.7.6 --- funcext/TSOffice/TOfficeObj.tsf | 2 +- funcext/TSOffice/TSDocxFile.tsf | 2 +- funcext/TSOffice/TSXlsxFile.tsf | 10 +++++----- funcext/TSOffice/worksheet/xlsxWorkBook.tsf | 10 ++++++++-- 更新日志.md | 9 +++++++++ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/funcext/TSOffice/TOfficeObj.tsf b/funcext/TSOffice/TOfficeObj.tsf index 2681538..204da3e 100644 --- a/funcext/TSOffice/TOfficeObj.tsf +++ b/funcext/TSOffice/TOfficeObj.tsf @@ -1,4 +1,4 @@ -// Version 1.7.5 +// Version 1.7.6 Function TOfficeObj(n); Begin case lowercase(n) of diff --git a/funcext/TSOffice/TSDocxFile.tsf b/funcext/TSOffice/TSDocxFile.tsf index c04f745..e088e51 100644 --- a/funcext/TSOffice/TSDocxFile.tsf +++ b/funcext/TSOffice/TSDocxFile.tsf @@ -1,4 +1,4 @@ -// Version 1.7.5 +// Version 1.7.6 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 cf6a902..ea1f488 100644 --- a/funcext/TSOffice/TSXlsxFile.tsf +++ b/funcext/TSOffice/TSXlsxFile.tsf @@ -1,4 +1,4 @@ -// Version 1.7.5 +// Version 1.7.6 Type TSXlsxFile = Class ///Version: V1.0 2022-08-08 ///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。 @@ -649,9 +649,9 @@ Type TSXlsxFile = Class ///visible: boolean Function SetColVisible(sheet, col, visible) Begin - [err, col] := ColumnNameToNumber(col); + [err, new_col] := ColumnNameToNumber(col); if err then return "Col error."; - return workbook_.SetColVisible(class(TSXml).CurCodePageToUtf8(sheet), col, visible); + return workbook_.SetColVisible(class(TSXml).CurCodePageToUtf8(sheet), new_col, visible); End; ///获取列可见性 @@ -660,9 +660,9 @@ Type TSXlsxFile = Class ///返回: [err, visible:int] Function GetColVisble(sheet, col); Begin - [err, col] := ColumnNameToNumber(col); + [err, new_col] := ColumnNameToNumber(col); if err then return array(-1, col); - return workbook_.GetColVisble(class(TSXml).CurCodePageToUtf8(sheet), col); + return workbook_.GetColVisble(class(TSXml).CurCodePageToUtf8(sheet), new_col); End; ///设置工作表页边距 diff --git a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf index 889d4af..b2041ce 100644 --- a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf +++ b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf @@ -419,7 +419,8 @@ Type xlsxWorkBook = Class for i:=0 to length(sheetNames_)-1 do Begin sheetNames_[i]['rid'] := 'rId' + inttostr(i + 1); //重置rId oldname := sheetNames_[i]['file']; - newname := sheetPrefix_ + inttostr(i + 1) + '.xml'; + fdir := ExtractFileDir(oldname); + newname := fdir + "/" + "sheet" + inttostr(i + 1) + '.xml'; sheetNames_[i]['file'] := newname; if oldname <> newname then Begin n := vselect thisrowindex from files where ['FileName'] = oldname end; @@ -473,7 +474,7 @@ Type xlsxWorkBook = Class node.SetAttribute('sheetId', sheetNames_[i]['sheetId']); node.SetAttribute('r:id', sheetNames_[i]['rid']); End; - //workbook.Print(); + // workbook.Print(); //设置docProps/app.xml app := GetXmlFileObj(class(TSXml).GetFileName('docProps_app')); @@ -899,6 +900,11 @@ Type xlsxWorkBook = Class Function SetRowHeight(sheet, row, height); Begin obj := GetSheetObj(sheet); + if not obj.RowIsExists(row) then + begin + axis := CoordinatesToCellName(1, row, False)[1]; + if not obj.CellIsExists(axis) then SetCellValue(sheet, axis, ''); + end obj.SetAttribute(row, array('ht': height, "customHeight": 1)); End diff --git a/更新日志.md b/更新日志.md index 612eebd..412489f 100644 --- a/更新日志.md +++ b/更新日志.md @@ -1,5 +1,14 @@ # 更新日志 +## 2025-1-8 + +### V1.7.6 + +#### excel + +1. **fix**:`SetRowHeight`单元格不存在无法设置 +2. **fix**:`Set[Get]ColVisible`修改传入的列参数 + ## 2025-1-7 ### V1.7.5