sheetra 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,10 +5,42 @@ export declare class ExportBuilder {
5
5
  private currentSheet;
6
6
  constructor(sheetName?: string);
7
7
  addHeaderRow(headers: string[], style?: any): this;
8
- addDataRows(data: any[], fields?: string[]): this;
8
+ /**
9
+ * Add multiple data rows to the sheet
10
+ * @param data Array of row data
11
+ * @param fields Optional array of field names (for object data)
12
+ * @param styles Optional array of styles per row or per cell
13
+ */
14
+ addDataRows(data: any[], fields?: string[], styles?: (import('../types').CellStyle | import('../types').CellStyle[] | undefined)[]): this;
9
15
  addSection(config: SectionConfig): this;
10
16
  addSections(sections: SectionConfig[]): this;
11
17
  setColumnWidths(widths: number[]): this;
18
+ /**
19
+ * Merge cells in the current worksheet
20
+ * @param startRow Start row index (0-based)
21
+ * @param startCol Start column index (0-based)
22
+ * @param endRow End row index (0-based)
23
+ * @param endCol End column index (0-based)
24
+ */
25
+ mergeCells(startRow: number, startCol: number, endRow: number, endCol: number): this;
26
+ /**
27
+ * Set alignment for a specific cell
28
+ * @param row Row index (0-based)
29
+ * @param col Column index (0-based)
30
+ * @param horizontal Horizontal alignment
31
+ * @param vertical Vertical alignment (optional)
32
+ */
33
+ setAlignment(row: number, col: number, horizontal: 'left' | 'center' | 'right', vertical?: 'top' | 'middle' | 'bottom'): this;
34
+ /**
35
+ * Set alignment for a range of cells
36
+ * @param startRow Start row index (0-based)
37
+ * @param startCol Start column index (0-based)
38
+ * @param endRow End row index (0-based)
39
+ * @param endCol End column index (0-based)
40
+ * @param horizontal Horizontal alignment
41
+ * @param vertical Vertical alignment (optional)
42
+ */
43
+ setRangeAlignment(startRow: number, startCol: number, endRow: number, endCol: number, horizontal: 'left' | 'center' | 'right', vertical?: 'top' | 'middle' | 'bottom'): this;
12
44
  autoSizeColumns(): this;
13
45
  addStyle(style: any): this;
14
46
  private groupData;
@@ -25,6 +25,18 @@ export declare class SheetBuilder {
25
25
  * @param style Optional style for all headers
26
26
  */
27
27
  addHeaderRow(headers: string[], style?: CellStyle): this;
28
+ /**
29
+ * Set the width of a specific column
30
+ * @param colIndex Column index
31
+ * @param width Width to set
32
+ */
33
+ setColumnWidth(colIndex: number, width: number): this;
34
+ /**
35
+ * Set the height of a specific row
36
+ * @param rowIndex Row index
37
+ * @param height Height to set
38
+ */
39
+ setRowHeight(rowIndex: number, height: number): this;
28
40
  /**
29
41
  * Add a title row
30
42
  * @param title Title text
@@ -1222,10 +1222,42 @@ declare class ExportBuilder {
1222
1222
  private currentSheet;
1223
1223
  constructor(sheetName?: string);
1224
1224
  addHeaderRow(headers: string[], style?: any): this;
1225
- addDataRows(data: any[], fields?: string[]): this;
1225
+ /**
1226
+ * Add multiple data rows to the sheet
1227
+ * @param data Array of row data
1228
+ * @param fields Optional array of field names (for object data)
1229
+ * @param styles Optional array of styles per row or per cell
1230
+ */
1231
+ addDataRows(data: any[], fields?: string[], styles?: (CellStyle | CellStyle[] | undefined)[]): this;
1226
1232
  addSection(config: SectionConfig): this;
1227
1233
  addSections(sections: SectionConfig[]): this;
1228
1234
  setColumnWidths(widths: number[]): this;
1235
+ /**
1236
+ * Merge cells in the current worksheet
1237
+ * @param startRow Start row index (0-based)
1238
+ * @param startCol Start column index (0-based)
1239
+ * @param endRow End row index (0-based)
1240
+ * @param endCol End column index (0-based)
1241
+ */
1242
+ mergeCells(startRow: number, startCol: number, endRow: number, endCol: number): this;
1243
+ /**
1244
+ * Set alignment for a specific cell
1245
+ * @param row Row index (0-based)
1246
+ * @param col Column index (0-based)
1247
+ * @param horizontal Horizontal alignment
1248
+ * @param vertical Vertical alignment (optional)
1249
+ */
1250
+ setAlignment(row: number, col: number, horizontal: 'left' | 'center' | 'right', vertical?: 'top' | 'middle' | 'bottom'): this;
1251
+ /**
1252
+ * Set alignment for a range of cells
1253
+ * @param startRow Start row index (0-based)
1254
+ * @param startCol Start column index (0-based)
1255
+ * @param endRow End row index (0-based)
1256
+ * @param endCol End column index (0-based)
1257
+ * @param horizontal Horizontal alignment
1258
+ * @param vertical Vertical alignment (optional)
1259
+ */
1260
+ setRangeAlignment(startRow: number, startCol: number, endRow: number, endCol: number, horizontal: 'left' | 'center' | 'right', vertical?: 'top' | 'middle' | 'bottom'): this;
1229
1261
  autoSizeColumns(): this;
1230
1262
  addStyle(style: any): this;
1231
1263
  private groupData;
@@ -1261,6 +1293,18 @@ declare class SheetBuilder {
1261
1293
  * @param style Optional style for all headers
1262
1294
  */
1263
1295
  addHeaderRow(headers: string[], style?: CellStyle): this;
1296
+ /**
1297
+ * Set the width of a specific column
1298
+ * @param colIndex Column index
1299
+ * @param width Width to set
1300
+ */
1301
+ setColumnWidth(colIndex: number, width: number): this;
1302
+ /**
1303
+ * Set the height of a specific row
1304
+ * @param rowIndex Row index
1305
+ * @param height Height to set
1306
+ */
1307
+ setRowHeight(rowIndex: number, height: number): this;
1264
1308
  /**
1265
1309
  * Add a title row
1266
1310
  * @param title Title text
@@ -1653,12 +1697,30 @@ declare class SectionBuilder {
1653
1697
 
1654
1698
  declare class ExcelWriter {
1655
1699
  static write(workbook: Workbook, _options: ExportOptions): Promise<Blob>;
1700
+ /**
1701
+ * Collect all unique styles from sheets
1702
+ */
1703
+ private static collectStyles;
1704
+ /**
1705
+ * Register a style and get its cellXf index
1706
+ */
1707
+ private static registerStyle;
1708
+ /**
1709
+ * Get style index for a cell style
1710
+ */
1711
+ private static getStyleIndex;
1712
+ private static serializeFont;
1713
+ private static serializeFill;
1714
+ private static serializeBorder;
1715
+ private static serializeAlignment;
1656
1716
  private static escapeXml;
1657
1717
  private static generateContentTypes;
1658
1718
  private static generateRels;
1659
1719
  private static generateWorkbook;
1660
1720
  private static generateWorkbookRels;
1661
1721
  private static generateStyles;
1722
+ private static generateBorderEdge;
1723
+ private static colorToARGB;
1662
1724
  private static generateSharedStrings;
1663
1725
  private static generateWorksheet;
1664
1726
  private static collectAllStrings;
@@ -2,12 +2,30 @@ import { Workbook } from '../core/workbook';
2
2
  import { ExportOptions } from '../types';
3
3
  export declare class ExcelWriter {
4
4
  static write(workbook: Workbook, _options: ExportOptions): Promise<Blob>;
5
+ /**
6
+ * Collect all unique styles from sheets
7
+ */
8
+ private static collectStyles;
9
+ /**
10
+ * Register a style and get its cellXf index
11
+ */
12
+ private static registerStyle;
13
+ /**
14
+ * Get style index for a cell style
15
+ */
16
+ private static getStyleIndex;
17
+ private static serializeFont;
18
+ private static serializeFill;
19
+ private static serializeBorder;
20
+ private static serializeAlignment;
5
21
  private static escapeXml;
6
22
  private static generateContentTypes;
7
23
  private static generateRels;
8
24
  private static generateWorkbook;
9
25
  private static generateWorkbookRels;
10
26
  private static generateStyles;
27
+ private static generateBorderEdge;
28
+ private static colorToARGB;
11
29
  private static generateSharedStrings;
12
30
  private static generateWorksheet;
13
31
  private static collectAllStrings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sheetra",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Powerful Excel/CSV/JSON export library with zero dependencies",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",