File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -1297,6 +1297,30 @@ impl Worksheet {
1297
1297
) ) ?;
1298
1298
Ok ( self . clone ( ) )
1299
1299
}
1300
+
1301
+ #[ wasm_bindgen( js_name = "setRowHeight" ) ]
1302
+ pub fn set_row_height (
1303
+ & mut self ,
1304
+ row : xlsx:: RowNum ,
1305
+ height : f64 ,
1306
+ ) -> WasmResult < Worksheet > {
1307
+ let mut book = self . workbook . lock ( ) . unwrap ( ) ;
1308
+ let sheet = book. worksheet_from_index ( self . index ) . unwrap ( ) ;
1309
+ let _ = map_xlsx_error ( sheet. set_row_height ( row, height) ) ?;
1310
+ Ok ( self . clone ( ) )
1311
+ }
1312
+
1313
+ #[ wasm_bindgen( js_name = "setRowHeightPixels" ) ]
1314
+ pub fn set_row_height_pixels (
1315
+ & mut self ,
1316
+ row : xlsx:: RowNum ,
1317
+ height : u16 ,
1318
+ ) -> WasmResult < Worksheet > {
1319
+ let mut book = self . workbook . lock ( ) . unwrap ( ) ;
1320
+ let sheet = book. worksheet_from_index ( self . index ) . unwrap ( ) ;
1321
+ let _ = map_xlsx_error ( sheet. set_row_height_pixels ( row, height) ) ?;
1322
+ Ok ( self . clone ( ) )
1323
+ }
1300
1324
1301
1325
#[ wasm_bindgen( js_name = "setRangeWithFormat" ) ]
1302
1326
pub fn set_range_format (
Original file line number Diff line number Diff line change @@ -159,3 +159,24 @@ describe("xlsx-wasm test", () => {
159
159
expect ( actual ) . matchXlsx ( expected ) ;
160
160
} ) ;
161
161
} ) ;
162
+
163
+ describe ( "xlsx-wasm test" , ( ) => {
164
+ test ( 'use width and height' , async ( ) => {
165
+ // Arrange
166
+ const workbook = new Workbook ( ) ;
167
+ const worksheet = workbook . addWorksheet ( ) ;
168
+
169
+ // Act
170
+ worksheet . setColumnWidth ( 0 , 16 ) ;
171
+ worksheet . setColumnRangeWidth ( 1 , 2 , 32 ) ;
172
+ worksheet . setColumnWidthPixels ( 4 , 100 ) ;
173
+
174
+ worksheet . setRowHeight ( 0 , 24 ) ;
175
+ worksheet . setRowHeightPixels ( 1 , 100 ) ; // 100 pixels = 75
176
+
177
+ // Assert
178
+ const actual = await readXlsx ( workbook . saveToBufferSync ( ) ) ;
179
+ const expected = await readXlsxFile ( "./expected/format_width_height.xlsx" ) ;
180
+ expect ( actual ) . matchXlsx ( expected ) ;
181
+ } ) ;
182
+ } ) ;
You can’t perform that action at this time.
0 commit comments