-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically support line breaks for both PPTX and XLSX. Fix a bug with using effects.
- Loading branch information
1 parent
b30fb9b
commit 8481a0c
Showing
5 changed files
with
62 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,7 @@ function makeXlsx ( genobj, new_type, options, gen_private, type_info ) { | |
// console.log ( genobj.generate_data.shared_strings.length ); | ||
} // Endif. | ||
} | ||
|
||
/// | ||
/// @brief ???. | ||
/// | ||
|
@@ -153,7 +153,7 @@ function makeXlsx ( genobj, new_type, options, gen_private, type_info ) { | |
/// @return Text string. | ||
/// | ||
function cbMakeXlsStyles ( data ) { | ||
return gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml ( data ) + '<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="1"><font><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles><dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/></styleSheet>'; | ||
return gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml ( data ) + '<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="1"><font><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf applyAlignment="1" borderId="0" fillId="0" fontId="0" numFmtId="0" xfId="0"><alignment wrapText="1"/></xf></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles><dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/></styleSheet>'; | ||
} | ||
|
||
/// | ||
|
@@ -276,7 +276,7 @@ function makeXlsx ( genobj, new_type, options, gen_private, type_info ) { | |
|
||
return outCell; | ||
} | ||
|
||
/// | ||
/// @brief ???. | ||
/// | ||
|
@@ -313,21 +313,36 @@ function makeXlsx ( genobj, new_type, options, gen_private, type_info ) { | |
|
||
for ( var rowId = 0, total_size_y = data.sheet.data.length; rowId < total_size_y; rowId++ ) { | ||
if ( data.sheet.data[rowId] ) { | ||
outString += '<row r="' + (rowId + 1) + '" spans="1:2">'; | ||
// Patch by arnesten <[email protected]>: Automatically support line breaks if used in cell + calculates row height: | ||
var rowLines = 1; | ||
data.sheet.data[rowId].forEach(function (cellData) { | ||
if (typeof cellData === 'string') { | ||
var candidate = cellData.split('\n').length; | ||
rowLines = Math.max(rowLines, candidate); | ||
} | ||
}); | ||
outString += '<row r="' + (rowId + 1) + '" spans="1:' + (data.sheet.data[rowId].length) + '" ht="' + ( rowLines * 15 ) + '">'; | ||
// End of patch. | ||
|
||
for ( var columnId = 0, total_size_x = data.sheet.data[rowId].length; columnId < total_size_x; columnId++ ) { | ||
if ( typeof data.sheet.data[rowId][columnId] != 'undefined' ) { | ||
var cellData = data.sheet.data[rowId][columnId]; | ||
if ( typeof cellData != 'undefined' ) { | ||
var isString = ''; | ||
var cellOutData = '0'; | ||
|
||
switch ( typeof data.sheet.data[rowId][columnId] ) { | ||
switch ( typeof cellData ) { | ||
case 'number': | ||
cellOutData = data.sheet.data[rowId][columnId]; | ||
cellOutData = cellData; | ||
break; | ||
|
||
case 'string': | ||
isString = ' t="s"'; | ||
cellOutData = genobj.generate_data.cell_strings[data.id][rowId][columnId]; | ||
if (cellData.indexOf('\n') >= 0) { | ||
isString = ' s="1" t="s"'; | ||
} | ||
else { | ||
isString = ' t="s"'; | ||
} | ||
break; | ||
} // End of switch. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters