Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, it is possible to use SheetJS/xlsx (nodejs module) to access the style (bold/italic/underline/strikethrough) of cells in Excel documents.

The xlsx module allows you to read and manipulate Excel files programmatically. You can use the style property of a cell object to access its formatting information, including the font weight, italic, underline, and strikethrough properties.

Here's an example of how to access the style of a cell in an Excel file using SheetJS/xlsx:

const XLSX = require('xlsx');
const workbook = XLSX.readFile('example.xlsx');
const worksheet = workbook.Sheets['Sheet1'];

// Get the cell at row 1, column A
const cell = worksheet['A1'];

// Get the font object from the cell's style
const font = cell.s && worksheet['!fonts'] && worksheet['!fonts'][cell.s].name;

// Check if the font is bold
const isBold = font && font.match(/bold/i);

// Check if the font is italic
const isItalic = font && font.match(/italic/i);

// Check if the cell has underline or strikethrough
const hasUnderline = cell && cell.s && cell.s.u;
const hasStrikethrough = cell && cell.s && cell.s.strike;

console.log('This cell is', isBold ? 'bold' : 'not bold');
console.log('This cell is', isItalic ? 'italic' : 'not italic');
console.log('This cell has', hasUnderline ? 'underline' : 'no underline');
console.log('This cell has', hasStrikethrough ? 'strikethrough' : 'no strikethrough');