1
1
# MR Excel ` 5.0.0 `
2
2
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 )
4
4
5
5
MR-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 ) **
6
6
@@ -17,6 +17,7 @@ MR-Excel is a JavaScript library designed for reading and writing Excel files. T
17
17
- [ ** ` generateExcel ` ** ] ( #generate-excel )
18
18
- [ ** ` How to use generateExcel ` ** ] ( #generate-excel-usage )
19
19
- [ ** ` General ` ** ] ( #general-option )
20
+ - [ ** ` 🆕 fetch ` ** ] ( #fetch )
20
21
- [ ** ` Header ` ** ] ( #header )
21
22
- [ ** ` Formula ` ** ] ( #formula )
22
23
- [ ** ` Time, Math, Custom Formula & etc ` ** ] ( #new-formula )
@@ -1764,6 +1765,37 @@ ExcelTable.generateExcel(data).then((res) => {
1764
1765
1765
1766
</details >
1766
1767
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
+
1767
1799
## Header Option [ ⬆️] ( #table-of-contents )
1768
1800
1769
1801
<a id =" header " ></a >
@@ -7753,14 +7785,14 @@ export interface ExcelTableOption {
7753
7785
creator? : string ;
7754
7786
backend? : boolean ;
7755
7787
activateConditionalFormatting? : boolean ;
7788
+ fetch? : Function ;
7756
7789
fileName? : string ;
7757
7790
generateType? : " nodebuffer" | " array" | " binarystring" | " base64" ;
7758
7791
addDefaultTitleStyle? : boolean ;
7759
7792
created? : string ;
7760
7793
modified? : string ;
7761
7794
numberOfColumn? : number ;
7762
7795
createType? : string ;
7763
- mapSheetDataOption? : any ;
7764
7796
styles? : Styles ;
7765
7797
}
7766
7798
@@ -7770,12 +7802,19 @@ export interface Sheet extends SheetOption {
7770
7802
}
7771
7803
export interface SheetOption {
7772
7804
withoutHeader? : boolean ;
7805
+ mapSheetDataOption? : {
7806
+ outlineLevel? : string ;
7807
+ hidden? : string ;
7808
+ height? : string ;
7809
+ };
7810
+ backgroundImage? : string ;
7773
7811
conditionalFormatting? : ConditionalFormatting [];
7774
7812
multiStyleCondition? : MultiStyleConditionFunction ;
7775
7813
useSplitBaseOnMatch? : boolean ;
7776
7814
convertStringToNumber? : boolean ;
7777
7815
images? : ImageTypes [];
7778
7816
formula? : Formula ;
7817
+ pageOption? : PageOption ;
7779
7818
name? : string ;
7780
7819
title? : Title ;
7781
7820
shiftTop? : number ;
@@ -7789,26 +7828,103 @@ export interface SheetOption {
7789
7828
commentCondition? : CommentConditionFunction ;
7790
7829
sortAndFilter? : SortAndFilter ;
7791
7830
state? : " hidden" | " visible" ;
7792
- headerRowOption? : any ;
7831
+ headerRowOption? : object ;
7793
7832
protectionOption? : ProtectionOption ;
7794
7833
headerHeight? : number ;
7795
7834
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 ;
7796
7911
}
7797
7912
export interface Header {
7798
7913
label: string ;
7799
7914
text: string ;
7800
7915
size? : number ;
7801
7916
multiStyleValue? : MultiStyleValue ;
7802
7917
comment? : Comment | string ;
7803
- conditionalFormatting? : ConditionalFormatting ;
7918
+ conditionalFormatting? : ConditionalFormattingOption ;
7804
7919
formula? : {
7805
7920
type: FormulaType ;
7806
7921
styleId? : string ;
7807
7922
};
7808
7923
}
7924
+ export type StyleType = " conditionalFormatting" | " CF" | " headerFooter" | " HF" ;
7809
7925
export interface StyleBody {
7810
7926
fontFamily? : string ;
7811
- type? : string ;
7927
+ type? : StyleType ;
7812
7928
size? : number ;
7813
7929
index? : number ;
7814
7930
alignment? : AlignmentOption ;
@@ -7866,10 +7982,8 @@ export type ProtectionOptionKey =
7866
7982
| " sort"
7867
7983
| " autoFilter"
7868
7984
| " pivotTables" ;
7869
- export interface ConditionalFormatting {
7985
+ export interface ConditionalFormattingOption {
7870
7986
type: " cells" | " dataBar" | " iconSet" | " colorScale" | " top" ;
7871
- start: string ;
7872
- end: string ;
7873
7987
operator? : string ;
7874
7988
value? : number | string ;
7875
7989
priority? : number ;
@@ -7878,6 +7992,10 @@ export interface ConditionalFormatting {
7878
7992
styleId? : string ;
7879
7993
percent? : number ;
7880
7994
}
7995
+ export interface ConditionalFormatting extends ConditionalFormattingOption {
7996
+ start: string ;
7997
+ end: string ;
7998
+ }
7881
7999
export interface ImageTypes {
7882
8000
url: string ;
7883
8001
from: string ;
@@ -7911,11 +8029,13 @@ export type AlignmentOptionKey =
7911
8029
| " readingOrder"
7912
8030
| " textRotation"
7913
8031
| " indent" ;
8032
+ export type AlignmentHorizontal = " center" | " left" | " right" ;
8033
+ export type AlignmentVertical = " center" | " top" | " bottom" ;
7914
8034
export 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 ;
7919
8039
readingOrder? : " 1" | " 2" | 2 | 1 ;
7920
8040
textRotation? : number ;
7921
8041
indent? : number ;
@@ -7958,6 +8078,7 @@ export interface Comment {
7958
8078
styleId? : string ;
7959
8079
author? : string ;
7960
8080
}
8081
+
7961
8082
export interface MergeRowConditionMap {
7962
8083
[columnKey : string ]: {
7963
8084
inProgress: boolean ;
@@ -8027,6 +8148,7 @@ export interface Checkbox {
8027
8148
export type NoArgFormulaType =
8028
8149
| " NOW"
8029
8150
| " TODAY"
8151
+ | " HOUR"
8030
8152
| " NOW_YEAR"
8031
8153
| " NOW_HOUR"
8032
8154
| " NOW_SECOND"
@@ -8046,6 +8168,7 @@ export type SingleRefFormulaType =
8046
8168
| " LEFT"
8047
8169
| " ABS"
8048
8170
| " POWER"
8171
+ | " MOD"
8049
8172
| " FLOOR"
8050
8173
| " CEILING"
8051
8174
| " ROUND"
@@ -8055,6 +8178,7 @@ export type SingleRefFormulaType =
8055
8178
| " TAN"
8056
8179
| " COT"
8057
8180
| " COUNTIF"
8181
+ | " SUMIF"
8058
8182
| " TRIM" ;
8059
8183
export interface FormatMap {
8060
8184
[format : string ]: {
@@ -8126,8 +8250,18 @@ export interface StyleMapper {
8126
8250
export interface MapComment {
8127
8251
[key : string ]: Comment | string ;
8128
8252
}
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
+ }
8130
8263
8264
+ ```
8131
8265
</details >
8132
8266
8133
8267
<a id =" migrate " ></a >
@@ -8184,6 +8318,12 @@ To migrate from Version 2 to Version 3, you need to follow the steps below:
8184
8318
8185
8319
## Release Notes [ ⬆️] ( #table-of-contents )
8186
8320
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
+
8187
8327
### Version 5.0.0 (2024-01-28)
8188
8328
8189
8329
#### New Features
0 commit comments