Add bold cell formatting option
Some checks failed
Build and Deploy / build (push) Failing after 14s
Build and Deploy / deploy (push) Has been skipped
Some checks failed
Build and Deploy / build (push) Failing after 14s
Build and Deploy / deploy (push) Has been skipped
This commit is contained in:
parent
c677c7267b
commit
8b60ceb39c
@ -6,11 +6,15 @@ import {serializeToString, createDocument} from './DOMUtils.js'
|
||||
/** @import {SheetCellRawContent, SheetName, SheetRawContent} from './types.js' */
|
||||
|
||||
const stylesXml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<office:document-styles
|
||||
<office:document-styles
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
office:version="1.2">
|
||||
<office:styles/>
|
||||
<office:styles>
|
||||
<style:style style:name="boldcell" style:family="table-cell">
|
||||
<style:text-properties fo:font-weight="bold"/>
|
||||
</style:style>
|
||||
</office:styles>
|
||||
<office:automatic-styles/>
|
||||
<office:master-styles/>
|
||||
</office:document-styles>`;
|
||||
@ -31,7 +35,7 @@ export async function createOdsFile(sheetsData) {
|
||||
// Create a new zip writer
|
||||
const zipWriter = new ZipWriter(new BlobWriter('application/vnd.oasis.opendocument.spreadsheet'));
|
||||
|
||||
// The “mimetype” file shall be the first file of the zip file.
|
||||
// The “mimetype” file shall be the first file of the zip file.
|
||||
// It shall not be compressed, and it shall not use an 'extra field' in its header.
|
||||
// https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part2-packages/OpenDocument-v1.3-os-part2-packages.html#__RefHeading__752809_826425813
|
||||
zipWriter.add(
|
||||
@ -60,7 +64,7 @@ export async function createOdsFile(sheetsData) {
|
||||
|
||||
/**
|
||||
* Generate the content.xml file with spreadsheet data
|
||||
* @param {Map<SheetName, SheetRawContent>} sheetsData
|
||||
* @param {Map<SheetName, SheetRawContent>} sheetsData
|
||||
* @returns {string}
|
||||
*/
|
||||
function generateContentFileXMLString(sheetsData) {
|
||||
@ -101,6 +105,10 @@ function generateContentFileXMLString(sheetsData) {
|
||||
const cellType = convertCellType(cell.type);
|
||||
cellNode.setAttribute('office:value-type', cellType);
|
||||
|
||||
if (cell.style && cell.style == "bold") {
|
||||
cellNode.setAttribute('table:style-name', "boldcell");
|
||||
}
|
||||
|
||||
// Add value attribute based on type
|
||||
if (cell.value !== null && cell.value !== undefined) {
|
||||
switch (cellType) {
|
||||
@ -141,7 +149,7 @@ function generateContentFileXMLString(sheetsData) {
|
||||
|
||||
/**
|
||||
* Convert cell type to OpenDocument format type
|
||||
* @param {SheetCellRawContent['type']} type
|
||||
* @param {SheetCellRawContent['type']} type
|
||||
* @returns {SheetCellRawContent['type']}
|
||||
*/
|
||||
function convertCellType(type) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user