作成日: 2024/08/09 最終更新日: 2025/11/13
文書種別
不具合
状況
修正済み
詳細
Excelファイルをインポートします。
この時、セルデータの存在しない列幅のみが変更された列では、シートの列幅がExcelファイルで設定されている列幅と異なります。
この時、セルデータの存在しない列幅のみが変更された列では、シートの列幅がExcelファイルで設定されている列幅と異なります。
回避方法
この問題はバージョン5.20252.42で修正されました。
修正版を適用しない場合の回避方法は次の通りです。
次善策(一部回避できない場合もあります)として、xlsxモジュールの_getSheetメソッドを書き換える方法がございます。
import * as wjXlsx from '@mescius/wijmo.xlsx';
let oldFun = wjXlsx._xlsx._getSheet;
wjXlsx._xlsx._getSheet = function (e, t, o, r) {
oldFun.call(this, e, t, o, r);
var h = o.sheets[t];
var a = e.split('<row ');
var cols = a[0].substring(a[0].indexOf('<cols>') + 6, a[0].indexOf('</cols>')).split('<col ');
let length = 1;
if (cols.length > 0) {
length = +this._getAttr(cols[cols.length - 1], 'min');
}
if (h.columns.length < length) {
var O = [],
D = [],
a = e.split("<row ");
if (a.length > 0 && a[0].indexOf("<cols>") > -1)
for (
var B =
(O = a[0]
.substring(a[0].indexOf("<cols>") + 6, a[0].indexOf("</cols>"))
.split("<col ")).length - 1;
B > 0;
B--
) {
var P = this._parseCharWidthToPixel(+this._getAttr(O[B], "width")),
I = null,
E = null;
O[B].indexOf("style") > -1 &&
(I = this._styles[+this._getAttr(O[B], "style")] || {
type: "General",
formatCode: null,
});
I &&
I.formatCode &&
"General" !== I.formatCode &&
(E = {
format:
I.formatCode && "General" !== I.formatCode ? I.formatCode : null,
numFormatId: I.numFormatId,
});
if (
r &&
I &&
(I.font ||
I.fillColor ||
I.hAlign ||
I.vAlign ||
I.wordWrap ||
I.borders)
) {
(E = E || {}).font = I.font;
E.fill = { color: I.fillColor };
E.borders = I.borders;
E.hAlign = I.hAlign;
E.vAlign = I.vAlign;
E.wordWrap = I.wordWrap;
}
var L = +this._getAttr(O[B], "min"),
M = +this._getAttr(O[B], "max");
for (let c = L - 1; c < M && c < h.maxCol; c++)
D[c] = {
visible: "1" !== this._getAttr(O[B], "hidden"),
autoWidth: "1" === this._getAttr(O[B], "bestFit"),
width: P,
style: E,
};
}
h.columns = D;
}
}