This commit is contained in:
csh 2025-01-08 15:31:04 +08:00
parent 3c16ce510a
commit 0f07603d73
5 changed files with 24 additions and 9 deletions

View File

@ -1,4 +1,4 @@
// Version 1.7.5 // Version 1.7.6
Function TOfficeObj(n); Function TOfficeObj(n);
Begin Begin
case lowercase(n) of case lowercase(n) of

View File

@ -1,4 +1,4 @@
// Version 1.7.5 // Version 1.7.6
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.7.5 // Version 1.7.6
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 等多种文档格式。
@ -649,9 +649,9 @@ Type TSXlsxFile = Class
///visible: boolean ///visible: boolean
Function SetColVisible(sheet, col, visible) Function SetColVisible(sheet, col, visible)
Begin Begin
[err, col] := ColumnNameToNumber(col); [err, new_col] := ColumnNameToNumber(col);
if err then return "Col error."; 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; End;
///获取列可见性 ///获取列可见性
@ -660,9 +660,9 @@ Type TSXlsxFile = Class
///返回: [err, visible:int] ///返回: [err, visible:int]
Function GetColVisble(sheet, col); Function GetColVisble(sheet, col);
Begin Begin
[err, col] := ColumnNameToNumber(col); [err, new_col] := ColumnNameToNumber(col);
if err then return array(-1, 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; End;
///设置工作表页边距 ///设置工作表页边距

View File

@ -419,7 +419,8 @@ Type xlsxWorkBook = Class
for i:=0 to length(sheetNames_)-1 do Begin for i:=0 to length(sheetNames_)-1 do Begin
sheetNames_[i]['rid'] := 'rId' + inttostr(i + 1); //重置rId sheetNames_[i]['rid'] := 'rId' + inttostr(i + 1); //重置rId
oldname := sheetNames_[i]['file']; oldname := sheetNames_[i]['file'];
newname := sheetPrefix_ + inttostr(i + 1) + '.xml'; fdir := ExtractFileDir(oldname);
newname := fdir + "/" + "sheet" + inttostr(i + 1) + '.xml';
sheetNames_[i]['file'] := newname; sheetNames_[i]['file'] := newname;
if oldname <> newname then Begin if oldname <> newname then Begin
n := vselect thisrowindex from files where ['FileName'] = oldname end; n := vselect thisrowindex from files where ['FileName'] = oldname end;
@ -473,7 +474,7 @@ Type xlsxWorkBook = Class
node.SetAttribute('sheetId', sheetNames_[i]['sheetId']); node.SetAttribute('sheetId', sheetNames_[i]['sheetId']);
node.SetAttribute('r:id', sheetNames_[i]['rid']); node.SetAttribute('r:id', sheetNames_[i]['rid']);
End; End;
//workbook.Print(); // workbook.Print();
//设置docProps/app.xml //设置docProps/app.xml
app := GetXmlFileObj(class(TSXml).GetFileName('docProps_app')); app := GetXmlFileObj(class(TSXml).GetFileName('docProps_app'));
@ -899,6 +900,11 @@ Type xlsxWorkBook = Class
Function SetRowHeight(sheet, row, height); Function SetRowHeight(sheet, row, height);
Begin Begin
obj := GetSheetObj(sheet); 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)); obj.SetAttribute(row, array('ht': height, "customHeight": 1));
End End

View File

@ -1,5 +1,14 @@
# 更新日志 # 更新日志
## 2025-1-8
### V1.7.6
#### excel
1. **fix**`SetRowHeight`单元格不存在无法设置
2. **fix**`Set[Get]ColVisible`修改传入的列参数
## 2025-1-7 ## 2025-1-7
### V1.7.5 ### V1.7.5