From 8b60ceb39c2b689afdc090f47403f54373fef491 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 5 Feb 2026 01:10:10 -0700 Subject: [PATCH] Add bold cell formatting option --- scripts/createOdsFile.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/createOdsFile.js b/scripts/createOdsFile.js index 9a014df..ae3e1cb 100644 --- a/scripts/createOdsFile.js +++ b/scripts/createOdsFile.js @@ -6,11 +6,15 @@ import {serializeToString, createDocument} from './DOMUtils.js' /** @import {SheetCellRawContent, SheetName, SheetRawContent} from './types.js' */ const stylesXml = ` - - + + + + + `; @@ -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} sheetsData + * @param {Map} 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) {