1.1.2 • Published 2 months ago

excel-build v1.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

excel-build

npm npm

Installation

npm install excel-build

Usage

FileBuilder

import { FileBuilder } from 'excel-build';

const excelFile = new FileBuilder('FILE_NAME');

excelFile.addSheet(sheet1).addSheet(sheet2).download();

API

MethodDescriptionTypeParameterReturns
addSheetAdd a sheet to the Excel file.functionSheetBuilderFileBuilder
downloadDownload the Excel file you created.function-void

SheetBuilder

import { SheetBuilder } from 'excel-build';

const data = [
  ['1', 'soohyun', 'sasha1107@naver.com', '01012345678', 'FE'],
  ['2', 'sasha', 'sasha981107@gmail.com', '01087654321', 'BE'],
];

const sheet1 = new SheetBuilder('sheet_1');
const sheet2 = new SheetBuilder('sheet_2')
  .appendThead(['id', 'name', 'email', 'phone', 'department'])
  .appendTbody(data)
  .mergeCell([0, 3], [4, 3]);

API

MethodDescriptionTypeParameterReturns
appendTheadAdds a header row to the table.function(theadArr: string[], option: any)SheetBuilder
appendRowAdds a row to the table.function(tRowArr: string\|number\|boolean\|Date[], option: any)SheetBuilder
appendTbodyAdds a row in array to the table.function(tbodyArr: string\|number\|boolean\|Date[][], option: any)SheetBuilder
appendCustomRowAdd custom style rows to the table.function(row: string\|number\|boolean\|Date[], option: any)SheetBuilder
mergeCellMerge the cells with the starting cell x0, y0 and the ending cell x1, y1 as factors.function(start: [number, number], end: [number, number])SheetBuilder
getWorkSheetReturns the sheet you created.function-SheetBuilder
getSheetNameReturns the name of the sheet you created.function-string
setColumnWidthSet the width for a specific column on the sheet.function(columnNumber: number, width: number)SheetBuilder

CellBuilder

const data = ['1', 'soohyun', 'sasha1107@naver.com', '01012345678', 'FE'];

sheet1.appendCustomRow(
  data.map((item) =>
    new CellBuilder(item)
      .setFontSize(20)
      .setFontColor('#FFFFFF')
      .setBackgroundColor('#555555')
      .setFontItalic()
      .build()
  )
);

API

MethodDescriptionTypeParameterReturns
setAlignMentVerticalSets the vertical alignment of cells.functioncenter | top | bottomCellBuilder
setAlignMentHorizontalSets the horizontal alignment of cells.functioncenter | left | rightCellBuilder
setAlignMentWrapTextAllow text wrapping.function-CellBuilder
setAlignMentTextRotation180 is rotated down 180 degrees, 255 is special, aligned verticallyfunction0 to 180, or 255CellBuilder
setBorderSets the border style for cells.functionnull | BorderStyleTypeCellBuilder
setBackgroundColorSets the background color of the cell.functionstring(HEX)CellBuilder
setFontColorSet the color of the font.functionstring(HEX)CellBuilder
setFontSizeSet the font size.functionnumberCellBuilder
setFontBoldSet the font in bold.function-CellBuilder
setFontItalicSet the font to italic.function-CellBuilder
setFontStrikeSet strikethrough in the font.function-CellBuilder
setFontUnderlineUnderline the font.function-CellBuilder
buildBuild a cell.function-CellBuilder
type BorderType =
  | 'dashDotDot'
  | 'dashDot'
  | 'dashed'
  | 'dotted'
  | 'hair'
  | 'mediumDashDotDot'
  | 'mediumDashDot'
  | 'mediumDashed'
  | 'medium'
  | 'slantDashDot'
  | 'thick'
  | 'thin';

type BorderStyleType = {
  top?: { style: BorderType; color: ColorType };
  bottom?: { style: BorderType; color: ColorType };
  left?: { style: BorderType; color: ColorType };
  right?: { style: BorderType; color: ColorType };
  diagonal?: {
    style: BorderType;
    color: ColorType;
    diagonalUp: boolean;
    diagonalDown: boolean;
  };
};
type ColorType = {
  rgb?: string;
  theme?: number;
  tint?: number;
};

🙏 Thanks

This project is a fork of SheetJS/sheetjs combined with code from sheetjs-style (by ShanaMaid) and sheetjs-style-v2 (by Raul Gonzalez) and xlsx-js-style (by gitbrent).

All projects are under the Apache 2.0 License

1.1.2

2 months ago

1.1.1

3 months ago

1.1.0

3 months ago

1.0.27

4 months ago

1.0.22

5 months ago

1.0.26

5 months ago

1.0.25

5 months ago

1.0.24

5 months ago

1.0.23

5 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.19

5 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago