File tree Expand file tree Collapse file tree 3 files changed +42
-14
lines changed
Expand file tree Collapse file tree 3 files changed +42
-14
lines changed Original file line number Diff line number Diff line change @@ -279,26 +279,37 @@ export interface Checkbox {
279279 endStr ?: string ;
280280}
281281export type FormulaType = "AVERAGE" | "SUM" | "COUNT" | "MAX" | "MIN" ;
282- export type RelativeFormulaType = "LEN" ;
282+ export type SingleRefFormulaType = "LEN" | "MODE"
283+ | "POWER"
284+ | "FLOOR"
285+ | "CEILING"
286+ | "ROUND"
287+ | "SQRT"
288+ | "COS"
289+ | "SIN"
290+ | "TAN"
291+ | "COT" ;
283292export interface FormatMap {
284293 [ format : string ] : {
285294 key : number ;
286295 value ?: string ;
287296 } ;
288297}
289298export interface Formula {
290- [ insertCell : string ] : FormulaSetting ;
299+ [ insertCell : string ] :
300+ | FormulaSetting
301+ | SingleRefFormulaSetting
291302}
292-
293303export interface FormulaSetting {
294304 type : FormulaType ;
295305 start : string ;
296306 end : string ;
297307 styleId ?: string ;
298308}
299- export interface RelativeFormulaSetting {
300- type : RelativeFormulaType ;
309+ export interface SingleRefFormulaSetting {
310+ type : SingleRefFormulaType ;
301311 refrenceCell : string ;
312+ value ?: number | string ;
302313 styleId ?: string ;
303314}
304315export interface StyleMapper {
Original file line number Diff line number Diff line change @@ -1253,7 +1253,9 @@ export async function generateExcel(data: ExcelTable) {
12531253 } ) ;
12541254 }
12551255 if ( formulaSheetObj ) {
1256- const remindFormulaKey = Object . keys ( formulaSheetObj ) ;
1256+ const remindFormulaKey = Object . keys ( formulaSheetObj ) . sort ( ( a , b ) =>
1257+ a > b ? 1 : - 1
1258+ ) ;
12571259 if ( remindFormulaKey . length ) {
12581260 let rF : {
12591261 [ row : number ] : string ;
@@ -1276,9 +1278,9 @@ export async function generateExcel(data: ExcelTable) {
12761278 }
12771279 } ) ;
12781280 Object . keys ( rF ) . forEach ( ( v ) => {
1279- const l = rF [ v as keyof object ] ;
1280- debugger
1281- let rowDataMap = rowMap [ v as keyof object ] ;
1281+ const val = v as keyof object ;
1282+ const l = rF [ val ] ;
1283+ let rowDataMap = rowMap [ val ] ;
12821284 if ( rowDataMap ) {
12831285 const body =
12841286 rowDataMap . startTag +
@@ -1297,6 +1299,11 @@ export async function generateExcel(data: ExcelTable) {
12971299 '" >' +
12981300 l +
12991301 "</row>" ;
1302+ rowMap [ val ] = {
1303+ startTag : '<row r="' + v + '" spans="1:' + colsLength + '" >' ,
1304+ endTag : "</row>" ,
1305+ details : l ,
1306+ } ;
13001307 }
13011308 } ) ;
13021309 }
Original file line number Diff line number Diff line change 11import {
22 FormulaSetting ,
3- RelativeFormulaSetting ,
3+ SingleRefFormulaSetting ,
44 Styles ,
55} from "../data-model/excel-table" ;
66
77export function generateCellRowCol (
88 string : string ,
9- formula : FormulaSetting | RelativeFormulaSetting ,
9+ formula : FormulaSetting | SingleRefFormulaSetting ,
1010 sheetIndex : number ,
1111 styles ?: Styles
1212) {
@@ -15,19 +15,29 @@ export function generateCellRowCol(
1515 let row = parseInt ( string . substr ( column . length ) ) ;
1616 let needCalcChain = false ;
1717 let chainCell = "" ;
18- if ( ( < RelativeFormulaSetting > formula ) . refrenceCell ) {
19- const form = < RelativeFormulaSetting > formula ;
18+ if ( ( < SingleRefFormulaSetting > formula ) . refrenceCell ) {
19+ const form = < SingleRefFormulaSetting > formula ;
20+ let value = "" ;
21+ if ( typeof form . value != "undefined" ) {
22+ value = "," + form . value ;
23+ }
24+ let className = "" ;
25+ if ( form . type == "COT" ) {
26+ className = "_xlfn." ;
27+ }
2028 const styleString =
21- "styleId" in formula ? 's="' + styles ! [ form . styleId ! ] . index + '"' : "" ;
29+ "styleId" in form ? 's="' + styles ! [ form . styleId ! ] . index + '"' : "" ;
2230 cell =
2331 '<c r="' +
2432 string +
2533 '" ' +
2634 styleString +
2735 "><f>" +
36+ className +
2837 formula . type +
2938 "(" +
3039 form . refrenceCell +
40+ value +
3141 ")</f></c>" ;
3242 chainCell = '<c r="' + string + '" i="' + sheetIndex + '"/>' ;
3343 } else {
You can’t perform that action at this time.
0 commit comments