diff --git a/src/gen-charts.ts b/src/gen-charts.ts
index 2b48edcdc..9bdbc8787 100644
--- a/src/gen-charts.ts
+++ b/src/gen-charts.ts
@@ -188,15 +188,13 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
{
let strTableXml = ''
if (chartObject.opts._type === CHART_TYPE.BUBBLE || chartObject.opts._type === CHART_TYPE.BUBBLE3D) {
- /*
- strTableXml += '
';
- strTableXml += '';
- data.forEach(function(obj,idx){ strTableXml += '' });
- */
+ //strTableXml += '';
+ //strTableXml += '';
+ //data.forEach(function(obj,idx){ strTableXml += '' });
} else if (chartObject.opts._type === CHART_TYPE.SCATTER) {
strTableXml +=
''
strTableXml += ''
@@ -206,7 +204,7 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
} else {
strTableXml +=
''
strTableXml += ''
@@ -229,11 +227,11 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
strSheetXml +=
''
if (chartObject.opts._type === CHART_TYPE.BUBBLE || chartObject.opts._type === CHART_TYPE.BUBBLE3D) {
- strSheetXml += ''
+ strSheetXml += ''
} else if (chartObject.opts._type === CHART_TYPE.SCATTER) {
- strSheetXml += ''
+ strSheetXml += ''
} else {
- strSheetXml += ''
+ strSheetXml += ''
}
strSheetXml += ''
@@ -260,10 +258,8 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
// A: Create header row first (NOTE: Start at index=1 as headers cols start with 'B')
strSheetXml += ''
strSheetXml += '0'
- for (let idxBc = 1; idxBc < intBubbleCols; idxBc++) {
- strSheetXml += '' // NOTE: use `t="s"` for label cols!
- strSheetXml += '' + idxBc + ''
- strSheetXml += ''
+ for (let idx = 1; idx < intBubbleCols; idx++) {
+ strSheetXml += `${idx}` // NOTE: add `t="s"` for label cols!
}
strSheetXml += '
'
@@ -276,14 +272,10 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
let idxColLtr = 1
for (let idy = 1; idy < data.length; idy++) {
// y-value
- strSheetXml += ''
- strSheetXml += '' + (data[idy].values[idx] || '') + ''
- strSheetXml += ''
+ strSheetXml += `${data[idy].values[idx] || ''}`
idxColLtr++
// y-size
- strSheetXml += ''
- strSheetXml += '' + (data[idy].sizes[idx] || '') + ''
- strSheetXml += ''
+ strSheetXml += `${data[idy].sizes[idx] || ''}`
idxColLtr++
}
strSheetXml += ''
@@ -311,10 +303,8 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
// A: Create header row first (NOTE: Start at index=1 as headers cols start with 'B')
strSheetXml += ''
strSheetXml += '0'
- for (let idxSd = 1; idxSd < data.length; idxSd++) {
- strSheetXml += '' // NOTE: use `t="s"` for label cols!
- strSheetXml += '' + idxSd + ''
- strSheetXml += ''
+ for (let idx = 1; idx < data.length; idx++) {
+ strSheetXml += `${idx}` // NOTE: add `t="s"` for label cols!
}
strSheetXml += '
'
@@ -325,9 +315,9 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
strSheetXml += '' + val + ''
// Add Y-Axis 1->N
for (let idy = 1; idy < data.length; idy++) {
- strSheetXml += ''
- strSheetXml += '' + (data[idy].values[idx] || data[idy].values[idx] === 0 ? data[idy].values[idx] : '') + ''
- strSheetXml += ''
+ strSheetXml += `${
+ data[idy].values[idx] || data[idy].values[idx] === 0 ? data[idy].values[idx] : ''
+ }`
}
strSheetXml += ''
})
@@ -359,13 +349,13 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
// A: Create header row first
strSheetXml += ''
data[0].labels.forEach((_labelsGroup, idx) => {
- strSheetXml += ''
+ strSheetXml += ''
strSheetXml += '0'
strSheetXml += ''
})
for (let idx = 1; idx <= data.length; idx++) {
// FIXME: Max cols is 52
- strSheetXml += '' // NOTE: use `t="s"` for label cols!
+ strSheetXml += '' // NOTE: use `t="s"` for label cols!
strSheetXml += '' + idx + ''
strSheetXml += ''
}
@@ -376,7 +366,7 @@ export function createExcelWorksheet(chartObject: ISlideRelChart, zip: JSZip): P
strSheetXml += ''
// Leading cols are reserved for the label groups
for (let idx2 = data[0].labels.length - 1; idx2 >= 0; idx2--) {
- strSheetXml += ''
+ strSheetXml += ''
strSheetXml += '' + (data.length + idx + idx2 * data[0].labels[0].length + 1) + ''
strSheetXml += ''
}
@@ -885,7 +875,7 @@ function makeChartType(chartType: CHART_NAME, data: IOptsChartData[], opts: ICha
strXml += ' '
} else {
strXml += ' '
- strXml += ' Sheet1!$A$2:$' + getExcelColName(obj.labels.length - 1) + '$' + (obj.labels[0].length + 1) + ''
+ strXml += ' Sheet1!$A$2:$' + getExcelColName(obj.labels.length) + '$' + (obj.labels[0].length + 1) + ''
strXml += ' '
strXml += ' '
obj.labels.forEach(labelsGroup => {
@@ -1009,7 +999,7 @@ function makeChartType(chartType: CHART_NAME, data: IOptsChartData[], opts: ICha
strXml += ' '
strXml += ' '
strXml += ' '
- strXml += ' Sheet1!$' + LETTERS[idx + 1] + '$1'
+ strXml += ' Sheet1!$' + getExcelColName(idx + 1) + '$1'
strXml += ' ' + obj.name + ''
strXml += ' '
strXml += ' '
@@ -1316,7 +1306,7 @@ function makeChartType(chartType: CHART_NAME, data: IOptsChartData[], opts: ICha
// A: ``
strXml += ' '
strXml += ' '
- strXml += ' Sheet1!$' + LETTERS[idxColLtr] + '$1'
+ strXml += ' Sheet1!$' + getExcelColName(idxColLtr + 1) + '$1'
strXml += ' ' + obj.name + ''
strXml += ' '
strXml += ' '
@@ -1377,7 +1367,7 @@ function makeChartType(chartType: CHART_NAME, data: IOptsChartData[], opts: ICha
// Y-Axis vals are this object's `values`
strXml += ''
strXml += ' '
- strXml += ' Sheet1!$' + getExcelColName(idxColLtr) + '$2:$' + getExcelColName(idxColLtr) + '$' + (data[0].values.length + 1) + ''
+ strXml += ' Sheet1!$' + getExcelColName(idxColLtr + 1) + '$2:$' + getExcelColName(idxColLtr + 1) + '$' + (data[0].values.length + 1) + ''
idxColLtr++
strXml += ' '
strXml += ' General'
@@ -1394,7 +1384,7 @@ function makeChartType(chartType: CHART_NAME, data: IOptsChartData[], opts: ICha
// E: ''
strXml += ' '
strXml += ' '
- strXml += ' Sheet1!$' + getExcelColName(idxColLtr) + '$2:$' + getExcelColName(idx + 2) + '$' + (obj.sizes.length + 1) + ''
+ strXml += ' Sheet1!$' + getExcelColName(idxColLtr + 1) + '$2:$' + getExcelColName(idx + 3) + '$' + (obj.sizes.length + 1) + ''
idxColLtr++
strXml += ' '
strXml += ' General'
@@ -1933,20 +1923,24 @@ function genXmlTitle(opts: IChartPropsTitle): string {
/**
* Calc and return excel column name for a given column length
- * @param {number} length - col length
- * @return {string} column name (ex: 'A2')
+ * @param colIndex column index
+ * @return column name
+ * @example 1 returns 'A'
+ * @example 27 returns 'AA'
*/
-function getExcelColName(length: number): string {
- let strName = ''
+function getExcelColName(colIndex: number): string {
+ let colStr = ''
+ let colIdx = colIndex - 1 // Subtract 1 so `LETTERS[columnIndex]` returns "A" etc
- if (length <= 26) {
- strName = LETTERS[length]
+ if (colIdx <= 25) {
+ // A-Z
+ colStr = LETTERS[colIdx]
} else {
- strName += LETTERS[Math.floor(length / LETTERS.length) - 1]
- strName += LETTERS[length % LETTERS.length]
+ // AA-ZZ (ZZ = index 702)
+ colStr = `${LETTERS[Math.floor(colIdx / LETTERS.length - 1)]}${LETTERS[colIdx % LETTERS.length]}`
}
- return strName
+ return colStr
}
/**
diff --git a/src/pptxgen.ts b/src/pptxgen.ts
index 9e31eecd0..e81f90223 100644
--- a/src/pptxgen.ts
+++ b/src/pptxgen.ts
@@ -97,7 +97,7 @@ import * as genMedia from './gen-media'
import * as genTable from './gen-tables'
import * as genXml from './gen-xml'
-const VERSION = '3.11.0-beta-20220522-1401'
+const VERSION = '3.11.0-beta-20220522-1701'
export default class PptxGenJS implements IPresentationProps {
// Property getters/setters