diff --git a/server/router/projects/index.js b/server/router/projects/index.js index becdbe7..e848376 100644 --- a/server/router/projects/index.js +++ b/server/router/projects/index.js @@ -403,7 +403,6 @@ module.exports = function (options) { } ] }).then(translationEntryVersions => { - console.log("Translation Entry: ", translationEntryVersions.length) const workbook = new XL.Workbook(); const cellWidth = 45 const cellHeight = 25 @@ -421,6 +420,7 @@ module.exports = function (options) { bold: true, }, alignment: { + horizontal: 'center', wrapText: true } }) @@ -432,6 +432,7 @@ module.exports = function (options) { bold: true, }, alignment: { + horizontal: 'center', wrapText: true } }) @@ -443,9 +444,15 @@ module.exports = function (options) { bold: true, }, alignment: { + horizontal: 'center', wrapText: true } }) + // Meta data for the translation and entry + worksheet.cell(4,4) + .string(translationEntryVersion.entryVersion.id) + worksheet.cell(4,5) + .string(translationEntryVersion.id) var cellIndex = 6 for (const i in translationEntryVersion.entryVersion.chapters) { @@ -459,31 +466,51 @@ module.exports = function (options) { .style({ alignment: { wrapText: true, - vertical: 'top' + vertical: 'justify' } }) - worksheet.cell(cellIndex,3) - .string(chunk.translation?.text ?? "") + const translationCell = worksheet.cell(cellIndex,3) .style({ alignment: { wrapText: true, - vertical: 'top' + vertical: 'justify' } }) + if (chunk.translation) { + translationCell.string(chunk.translation.text) + } + const textLength = chunk.text.length worksheet.row(cellIndex).setHeight( Math.ceil(Math.max(textLength/cellWidth, 1)*cellHeight) ) + + // Meta data... + // ID for chunk + worksheet.cell(cellIndex,4) + .string(chunk.id) + // ID for translation + worksheet.cell(cellIndex,5) + .string(chunk.translation?.id ?? "") + cellIndex++ } cellIndex++ } - // Format + // Format Columns worksheet.column(2).setWidth(cellWidth); worksheet.column(3).setWidth(cellWidth); + worksheet.column(4).hide(); + worksheet.column(5).hide(); + + // Format Rows... + worksheet.row(5).freeze() + worksheet.row(1).setHeight(5) + worksheet.row(3).setHeight(5) + worksheet.row(5).setHeight(5) }) workbook.write(`${project.name}.xlsx`, response); }).catch(error => {