odfjs/scripts/main.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-06-15 12:54:53 +02:00
//@ts-check
let _DOMParser
2024-06-15 12:54:53 +02:00
if(typeof DOMParser !== 'undefined' && Object(DOMParser) === DOMParser && DOMParser.prototype && typeof DOMParser.prototype.parseFromString === 'function'){
console.info('[ods-xlsx] Already existing DOMParser. Certainly in the browser')
_DOMParser = DOMParser
2024-06-15 12:54:53 +02:00
}
else{
console.info('[ods-xlsx] No native DOMParser. Certainly in Node.js')
2024-06-15 12:54:53 +02:00
const xmldom = await import('@xmldom/xmldom')
_DOMParser = xmldom.DOMParser
2024-06-15 12:54:53 +02:00
}
2024-06-16 13:57:12 +02:00
function parseXML(str){
return (new _DOMParser()).parseFromString(str, 'application/xml');
2024-06-16 13:57:12 +02:00
}
import {
_getODSTableRawContent,
_getXLSXTableRawContent
} from './shared.js'
2024-06-15 12:54:53 +02:00
/**
* @param {ArrayBuffer} odsArrBuff
* @returns {ReturnType<_getODSTableRawContent>}
2024-06-15 12:54:53 +02:00
*/
export function getODSTableRawContent(odsArrBuff){
return _getODSTableRawContent(odsArrBuff, parseXML)
2024-06-15 12:54:53 +02:00
}
2024-06-15 16:29:16 +02:00
/**
* @param {ArrayBuffer} xlsxArrBuff
* @returns {ReturnType<_getXLSXTableRawContent>}
2024-06-15 16:29:16 +02:00
*/
export function getXLSXTableRawContent(xlsxArrBuff){
return _getXLSXTableRawContent(xlsxArrBuff, parseXML)
2024-06-15 16:29:16 +02:00
}
2024-06-16 13:57:12 +02:00
export {
isRowNotEmpty,
// table-level exports
tableWithoutEmptyRows,
tableRawContentToValues,
tableRawContentToStrings,
tableRawContentToObjects,
} from './shared.js'
2024-06-15 16:29:16 +02:00