UNPKG

@fusioncharts/features

Version:

FusionCharts JavaScript charting framework

1 lines 4.57 kB
"use strict";exports.__esModule=true;exports.createWorkBookRel=createWorkBookRel;exports.generateSheet=generateSheet;exports.getStyles=getStyles;exports.getWorkBookSheet=getWorkBookSheet;exports.toWorkBookRel=toWorkBookRel;var templateSheet='<?xml version="1.0" ?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" '+'xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" '+'xmlns:mx="http://schemas.microsoft.com/office/mac/excel/2008/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" '+'xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" '+'xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">'+"<sheetData>{rows}</sheetData></worksheet>";function toWorkBookRel(sheet,i){return'<Relationship Id="'+sheet.rId+'" Target="worksheets/sheet'+i+'.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>'}function getWorkBookSheet(sheet){return'<sheet state="visible" name="'+sheet.name+'" sheetId="'+sheet.id+'" r:id="'+sheet.rId+'"/>'}function getStyles(){return'<?xml version="1.0" encoding="utf-8"?>\n <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">\n <numFmts count="0"></numFmts>\n <fonts count="2" x14ac:knownFonts="1" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">\n <font><sz val="10" /><color rgb="FF333333" /><name val="Calibri Body" /></font>\n <font><b/><sz val="10" /><name val="Calibri Body" /></font>\n </fonts>\n <fills count="2">\n <fill><patternFill patternType="none"/></fill>\n <fill><patternFill patternType="gray125"/></fill>\n </fills>\n <borders count="1"><border><left /><right /><top /><bottom /><diagonal /></border></borders>\n <cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>\n <cellXfs count="2">\n <xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyAlignment="1">\n <alignment verticial="center" horizontal="center" />\n </xf>\n <xf numFmtId="undefined" fontId="0" fillId="undefined" borderId="undefined" xfId="0" applyBorder="1" applyFill="1"></xf>\n </cellXfs>\n <cellStyles count="1">\n <cellStyle name="Normal" xfId="0" builtinId="0"/>\n </cellStyles><dxfs count="0"/></styleSheet>'}function generateSheet(sheet){return templateSheet.replace("{rows}",generateRows(sheet.rows))}function createWorkBookRel(){var newsheet='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';newsheet=newsheet+'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>';return newsheet+"</Relationships>"}function cellNameH(i){var rest=Math.floor(i/26)-1,s=rest>-1?cellNameH(rest):"";return s+"ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(i%26)}function cellName(colIndex,rowIndex){return cellNameH(colIndex)+rowIndex}function formatNumber(number){return number.replace(/'/g,"").replace(/"/g,"")}function generateCell(columnData,column,row){var cellData;if(row-1===0){cellData='<c s="0" r="'+cellName(column,row)+'"'}else{cellData='<c s="1" r="'+cellName(column,row)+'"'}if(isNaN(columnData)){return cellData+' t="inlineStr" ><is><t>'+checkSpecialChars(columnData)+"</t></is></c>"}return cellData+"><v>"+formatNumber(columnData)+"</v></c>"}function checkSpecialChars(specialStr){var val=specialStr;if(typeof val!=="string")val+="";return val&&RegExp(/[&<>"']/g.source).test(val)?replaceSpecialChars(val):val}function replaceSpecialChars(val){var replacedVal=val;replacedVal=replacedVal.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&#39;");return replacedVal}function generateCells(rowData,row){var cellObj=[];for(var column in rowData){cellObj.push(generateCell(rowData[column],parseInt(column,10),row))}return cellObj.join("")}function generateRow(rowData,row){var xlRowVal=row+1,xmlData='<row r="'+xlRowVal+'">';xmlData=xmlData+generateCells(rowData,xlRowVal);return xmlData+"</row>"}function generateRows(rows){var rowObj=[];for(var row in rows){rowObj.push(generateRow(rows[row],parseInt(row,10)))}return rowObj.join("")}