Place some metadata

This commit is contained in:
2022-01-04 02:30:55 +02:00
parent c41dfcb74f
commit e22f85a1aa

View File

@@ -403,7 +403,6 @@ module.exports = function (options) {
} }
] ]
}).then(translationEntryVersions => { }).then(translationEntryVersions => {
console.log("Translation Entry: ", translationEntryVersions.length)
const workbook = new XL.Workbook(); const workbook = new XL.Workbook();
const cellWidth = 45 const cellWidth = 45
const cellHeight = 25 const cellHeight = 25
@@ -421,6 +420,7 @@ module.exports = function (options) {
bold: true, bold: true,
}, },
alignment: { alignment: {
horizontal: 'center',
wrapText: true wrapText: true
} }
}) })
@@ -432,6 +432,7 @@ module.exports = function (options) {
bold: true, bold: true,
}, },
alignment: { alignment: {
horizontal: 'center',
wrapText: true wrapText: true
} }
}) })
@@ -443,9 +444,15 @@ module.exports = function (options) {
bold: true, bold: true,
}, },
alignment: { alignment: {
horizontal: 'center',
wrapText: true 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 var cellIndex = 6
for (const i in translationEntryVersion.entryVersion.chapters) { for (const i in translationEntryVersion.entryVersion.chapters) {
@@ -459,31 +466,51 @@ module.exports = function (options) {
.style({ .style({
alignment: { alignment: {
wrapText: true, wrapText: true,
vertical: 'top' vertical: 'justify'
} }
}) })
worksheet.cell(cellIndex,3) const translationCell = worksheet.cell(cellIndex,3)
.string(chunk.translation?.text ?? "")
.style({ .style({
alignment: { alignment: {
wrapText: true, wrapText: true,
vertical: 'top' vertical: 'justify'
} }
}) })
if (chunk.translation) {
translationCell.string(chunk.translation.text)
}
const textLength = chunk.text.length const textLength = chunk.text.length
worksheet.row(cellIndex).setHeight( worksheet.row(cellIndex).setHeight(
Math.ceil(Math.max(textLength/cellWidth, 1)*cellHeight) 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++
} }
cellIndex++ cellIndex++
} }
// Format // Format Columns
worksheet.column(2).setWidth(cellWidth); worksheet.column(2).setWidth(cellWidth);
worksheet.column(3).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); workbook.write(`${project.name}.xlsx`, response);
}).catch(error => { }).catch(error => {