Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(abc:st): correct width misalignment in export excel #1655

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/abc/st/st-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,17 @@ export class STExport {
const sheet: { [key: string]: NzSafeAny } = (sheets[opt.sheetname || 'Sheet1'] = {});
const dataLen = opt.data!.length;
let validColCount = 0;
let loseCount = 0;
const columns = opt.columens! as _STColumn[];
const columns = (opt.columens! as _STColumn[]).filter(
col => !(col.exported === false || !col.index || !(!col.buttons || col.buttons.length === 0))
);
if (columns.findIndex(w => w._width != null) !== -1) {
// wpx: width in screen pixels https://github.com/SheetJS/sheetjs#column-properties
sheet['!cols'] = columns.map(col => ({ wpx: col._width }));
}
for (let colIdx = 0; colIdx < columns.length; colIdx++) {
const col = columns[colIdx];
if (col.exported === false || !col.index || !(!col.buttons || col.buttons.length === 0)) {
++loseCount;
continue;
}
++validColCount;
const columnName = this.xlsxSrv.numberToSchema(colIdx + 1 - loseCount);
const columnName = this.xlsxSrv.numberToSchema(colIdx + 1);
sheet[`${columnName}1`] = {
t: 's',
v: typeof col.title === 'object' ? col.title.text : col.title
Expand Down