11# MR Excel ` 5.0.0 `
22
3- ![ Test] ( https://github.com/mohammadrezaeicode/github-action/actions/workflows/test.yml/badge.svg )
3+ ![ Test] ( https://github.com/mohammadrezaeicode/github-action/actions/workflows/test.yml/badge.svg ) [ ![ Release & Publish ] ( https://github.com/mohammadrezaeicode/mr-excel-repo/actions/workflows/release.yml/badge.svg )] ( https://github.com/mohammadrezaeicode/mr-excel-repo/actions/workflows/release.yml )
44
55MR-Excel is a JavaScript library designed for reading and writing Excel files. This library allows you to extract data from Excel files, and when it comes to writing, it offers a range of features such as commenting, styling, Formulas, merging cells,Grouping rows, conditional formatting (Excel), multi-style values, and functions that can be used for cell merging, adding styles and commenting functionalities. ` Since version 5.0.0, we exclusively build via Vite. The path of the TypeScript interface has been updated (link). For further details, refer to the TypeScript example. ` ** Example: [ Express] ( https://github.com/mohammadrezaeicode/mr-excel-repo/tree/main/example/express ) | [ CDN] ( https://github.com/mohammadrezaeicode/mr-excel-repo/tree/main/example/CDN ) | [ Typescript] ( https://github.com/mohammadrezaeicode/mr-excel-repo/tree/main/example/typescript ) | [ Angular] ( https://github.com/mohammadrezaeicode/mr-excel-repo/tree/main/example/angular ) **
66
@@ -17,6 +17,7 @@ MR-Excel is a JavaScript library designed for reading and writing Excel files. T
1717- [ ** ` generateExcel ` ** ] ( #generate-excel )
1818 - [ ** ` How to use generateExcel ` ** ] ( #generate-excel-usage )
1919 - [ ** ` General ` ** ] ( #general-option )
20+ - [ ** ` 🆕 fetch ` ** ] ( #fetch )
2021 - [ ** ` Header ` ** ] ( #header )
2122 - [ ** ` Formula ` ** ] ( #formula )
2223 - [ ** ` Time, Math, Custom Formula & etc ` ** ] ( #new-formula )
@@ -1764,6 +1765,37 @@ ExcelTable.generateExcel(data).then((res) => {
17641765
17651766</details >
17661767
1768+ <a id =" fetch " ></a >
1769+
1770+ ## 🆕 fetch Option [ ⬆️] ( #table-of-contents )
1771+
1772+ mr-Excel uses fetch (if the images option is used). If it is used with Node lower than 18.0.0, you may encounter problems. To fix this problem, you can add the fetch option. Here’s an example of how the function should look like:
1773+
1774+ ``` javascript
1775+ import fetch from " cross-fetch" ;
1776+ export async function callApi (url ) {
1777+ return await fetch (url).then ((res ) => {
1778+ return res .arrayBuffer ();
1779+ });
1780+ }
1781+ const data = {
1782+ fetch: callApi,
1783+ ...
1784+ sheet: [
1785+ {
1786+ images: [
1787+ {
1788+ url: " https://mohammadrezaeicode.github.io/mr-excel-page/img/ezgif.com-gif-maker.gif" ,
1789+ from: " H1" ,
1790+ type: " one" ,
1791+ },
1792+ ],
1793+ ...
1794+ },
1795+ ],
1796+ };
1797+ ```
1798+
17671799## Header Option [ ⬆️] ( #table-of-contents )
17681800
17691801<a id =" header " ></a >
@@ -7753,14 +7785,14 @@ export interface ExcelTableOption {
77537785 creator? : string ;
77547786 backend? : boolean ;
77557787 activateConditionalFormatting? : boolean ;
7788+ fetch? : Function ;
77567789 fileName? : string ;
77577790 generateType? : " nodebuffer" | " array" | " binarystring" | " base64" ;
77587791 addDefaultTitleStyle? : boolean ;
77597792 created? : string ;
77607793 modified? : string ;
77617794 numberOfColumn? : number ;
77627795 createType? : string ;
7763- mapSheetDataOption? : any ;
77647796 styles? : Styles ;
77657797}
77667798
@@ -7770,12 +7802,19 @@ export interface Sheet extends SheetOption {
77707802}
77717803export interface SheetOption {
77727804 withoutHeader? : boolean ;
7805+ mapSheetDataOption? : {
7806+ outlineLevel? : string ;
7807+ hidden? : string ;
7808+ height? : string ;
7809+ };
7810+ backgroundImage? : string ;
77737811 conditionalFormatting? : ConditionalFormatting [];
77747812 multiStyleCondition? : MultiStyleConditionFunction ;
77757813 useSplitBaseOnMatch? : boolean ;
77767814 convertStringToNumber? : boolean ;
77777815 images? : ImageTypes [];
77787816 formula? : Formula ;
7817+ pageOption? : PageOption ;
77797818 name? : string ;
77807819 title? : Title ;
77817820 shiftTop? : number ;
@@ -7789,26 +7828,103 @@ export interface SheetOption {
77897828 commentCondition? : CommentConditionFunction ;
77907829 sortAndFilter? : SortAndFilter ;
77917830 state? : " hidden" | " visible" ;
7792- headerRowOption? : any ;
7831+ headerRowOption? : object ;
77937832 protectionOption? : ProtectionOption ;
77947833 headerHeight? : number ;
77957834 checkbox? : Checkbox [];
7835+ viewOption? : ViewOption ;
7836+ rtl? : boolean ;
7837+ pageBreak? : PageBreak ;
7838+ asTable? : AsTableOption ;
7839+ }
7840+ export interface AsTableOption {
7841+ type? : " Light" | " Medium" | " Dark" ;
7842+ styleNumber? : number ;
7843+ firstColumn? : boolean ;
7844+ lastColumn? : boolean ;
7845+ rowStripes? : boolean ;
7846+ columnStripes? : boolean ;
7847+ }
7848+ export interface PageBreak {
7849+ row? : number [];
7850+ column? : number [];
7851+ }
7852+ export interface ViewStart {
7853+ t? : string ;
7854+ b? : string ;
7855+ r? : string ;
7856+ l? : string ;
7857+ one? : string ;
7858+ two? : string ;
7859+ }
7860+ export interface ViewOption {
7861+ type? : " pageLayout" | " pageBreakPreview" ;
7862+ hideGrid? : boolean ;
7863+ hideHeadlines? : boolean ;
7864+ hideRuler? : boolean ;
7865+ frozenOption? : {
7866+ type: " ROW" | " COLUMN" | " BOTH" | " R" | " C" | " B" ;
7867+ index:
7868+ | number
7869+ | {
7870+ r: number ;
7871+ c: number ;
7872+ };
7873+ };
7874+ splitOption? : {
7875+ type: " VERTICAL" | " HORIZONTAL" | " BOTH" | " V" | " H" | " B" ;
7876+ startAt? : ViewStart ;
7877+ split:
7878+ | number
7879+ | {
7880+ x: number ;
7881+ y: number ;
7882+ };
7883+ };
7884+ }
7885+ export interface HeaderFooterOption {
7886+ text? : string ;
7887+ styleId? : string ;
7888+ }
7889+ export interface HeaderFooterLocationMap {
7890+ l? : HeaderFooterOption ;
7891+ c? : HeaderFooterOption ;
7892+ r? : HeaderFooterOption ;
7893+ }
7894+ export interface HeaderFooterTypes {
7895+ odd? : HeaderFooterLocationMap ;
7896+ even? : HeaderFooterLocationMap ;
7897+ first? : HeaderFooterLocationMap ;
7898+ }
7899+ export interface PageOption {
7900+ margin? : {
7901+ left? : number ;
7902+ right? : number ;
7903+ top? : number ;
7904+ bottom? : number ;
7905+ header? : number ;
7906+ footer? : number ;
7907+ };
7908+ header? : HeaderFooterTypes ;
7909+ footer? : HeaderFooterTypes ;
7910+ isPortrait: boolean ;
77967911}
77977912export interface Header {
77987913 label: string ;
77997914 text: string ;
78007915 size? : number ;
78017916 multiStyleValue? : MultiStyleValue ;
78027917 comment? : Comment | string ;
7803- conditionalFormatting? : ConditionalFormatting ;
7918+ conditionalFormatting? : ConditionalFormattingOption ;
78047919 formula? : {
78057920 type: FormulaType ;
78067921 styleId? : string ;
78077922 };
78087923}
7924+ export type StyleType = " conditionalFormatting" | " CF" | " headerFooter" | " HF" ;
78097925export interface StyleBody {
78107926 fontFamily? : string ;
7811- type? : string ;
7927+ type? : StyleType ;
78127928 size? : number ;
78137929 index? : number ;
78147930 alignment? : AlignmentOption ;
@@ -7866,10 +7982,8 @@ export type ProtectionOptionKey =
78667982 | " sort"
78677983 | " autoFilter"
78687984 | " pivotTables" ;
7869- export interface ConditionalFormatting {
7985+ export interface ConditionalFormattingOption {
78707986 type: " cells" | " dataBar" | " iconSet" | " colorScale" | " top" ;
7871- start: string ;
7872- end: string ;
78737987 operator? : string ;
78747988 value? : number | string ;
78757989 priority? : number ;
@@ -7878,6 +7992,10 @@ export interface ConditionalFormatting {
78787992 styleId? : string ;
78797993 percent? : number ;
78807994}
7995+ export interface ConditionalFormatting extends ConditionalFormattingOption {
7996+ start: string ;
7997+ end: string ;
7998+ }
78817999export interface ImageTypes {
78828000 url: string ;
78838001 from: string ;
@@ -7911,11 +8029,13 @@ export type AlignmentOptionKey =
79118029 | " readingOrder"
79128030 | " textRotation"
79138031 | " indent" ;
8032+ export type AlignmentHorizontal = " center" | " left" | " right" ;
8033+ export type AlignmentVertical = " center" | " top" | " bottom" ;
79148034export interface AlignmentOption {
7915- horizontal? : " center " | " left " | " right " ;
7916- vertical? : " center " | " top " | " bottom " ;
7917- wrapText? : " 0" | " 1" | 2 | 1 ;
7918- shrinkToFit? : " 0" | " 1" | 2 | 1 ;
8035+ horizontal? : AlignmentHorizontal ;
8036+ vertical? : AlignmentVertical ;
8037+ wrapText? : " 0" | " 1" | 0 | 1 ;
8038+ shrinkToFit? : " 0" | " 1" | 0 | 1 ;
79198039 readingOrder? : " 1" | " 2" | 2 | 1 ;
79208040 textRotation? : number ;
79218041 indent? : number ;
@@ -7958,6 +8078,7 @@ export interface Comment {
79588078 styleId? : string ;
79598079 author? : string ;
79608080}
8081+
79618082export interface MergeRowConditionMap {
79628083 [columnKey : string ]: {
79638084 inProgress: boolean ;
@@ -8027,6 +8148,7 @@ export interface Checkbox {
80278148export type NoArgFormulaType =
80288149 | " NOW"
80298150 | " TODAY"
8151+ | " HOUR"
80308152 | " NOW_YEAR"
80318153 | " NOW_HOUR"
80328154 | " NOW_SECOND"
@@ -8046,6 +8168,7 @@ export type SingleRefFormulaType =
80468168 | " LEFT"
80478169 | " ABS"
80488170 | " POWER"
8171+ | " MOD"
80498172 | " FLOOR"
80508173 | " CEILING"
80518174 | " ROUND"
@@ -8055,6 +8178,7 @@ export type SingleRefFormulaType =
80558178 | " TAN"
80568179 | " COT"
80578180 | " COUNTIF"
8181+ | " SUMIF"
80588182 | " TRIM" ;
80598183export interface FormatMap {
80608184 [format : string ]: {
@@ -8126,8 +8250,18 @@ export interface StyleMapper {
81268250export interface MapComment {
81278251 [key : string ]: Comment | string ;
81288252}
8129- ```
8253+ export interface ThemeOption {
8254+ headerIndex? : number ;
8255+ rowIndex? : number ;
8256+ negativeColor? : boolean ;
8257+ headerColor? : string ;
8258+ rowColor? : string ;
8259+ headerBackgroundColor? : string ;
8260+ rowBackgroundColor? : string ;
8261+ fileName? : string ;
8262+ }
81308263
8264+ ```
81318265</details >
81328266
81338267<a id =" migrate " ></a >
@@ -8184,6 +8318,12 @@ To migrate from Version 2 to Version 3, you need to follow the steps below:
81848318
81858319## Release Notes [ ⬆️] ( #table-of-contents )
81868320
8321+ ### Version 5.1.0 (2024-01-31)
8322+
8323+ #### New Features
8324+
8325+ - The ` fetch ` option allows you to use your method to retrieve images and .xlsx files
8326+
81878327### Version 5.0.0 (2024-01-28)
81888328
81898329#### New Features
0 commit comments