Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit88cefd9

Browse files
committed
Merge branch 'lyhue1991-dev' into dev
2 parents580cc06 +8d61a8e commit88cefd9

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

‎src/danfojs-base/io/node/io.excel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const $readExcel = async (filePath: string, options: ExcelInputOptionsNode = {})
7171
constarrBufInt8=newUint8Array(arrBuf);
7272
constworkbook=read(arrBufInt8,{type:"array", ...parsingOptions});
7373
constworksheet=workbook.Sheets[workbook.SheetNames[sheet]];
74-
constdata=utils.sheet_to_json(worksheet);
74+
constdata=utils.sheet_to_json(worksheet,{defval:null});
7575
constdf=newDataFrame(data,frameConfig);
7676
resolve(df);
7777
});
@@ -89,7 +89,7 @@ const $readExcel = async (filePath: string, options: ExcelInputOptionsNode = {})
8989

9090
constworkbook=readFile(filePath,parsingOptions);
9191
constworksheet=workbook.Sheets[workbook.SheetNames[sheet]];
92-
constdata=utils.sheet_to_json(worksheet);
92+
constdata=utils.sheet_to_json(worksheet,{defval:null});
9393
constdf=newDataFrame(data,frameConfig);
9494
resolve(df);
9595
})

‎src/danfojs-node/test/io/excel.reader.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,23 @@ describe("toExcel", function () {
106106
assert.equal(fs.existsSync(filePath),true)
107107
});
108108

109+
it("handles null values correctly",asyncfunction(){
110+
constdata=[
111+
{'name':'Alice','age':25},
112+
{'name':null,'age':30},
113+
{'name':'Charlie','age':35}
114+
];
115+
constdf:any=newDataFrame(data);
116+
constfilePath=path.join(process.cwd(),"test","samples","people.xlsx");
117+
118+
toExcel(df,{ filePath,sheetName:'Sheet1'});
119+
constdf2:any=awaitreadExcel(filePath);
120+
121+
assert.deepEqual(df2.values,[
122+
['Alice',25],
123+
[null,30],
124+
['Charlie',35]
125+
]);
126+
assert.deepEqual(df2.columns,['name','age']);
127+
});
109128
})
1.27 KB
Binary file not shown.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp