#json #typescript #jspdf #jspdf-autotable
Вопрос:
Приведенный ниже код успешно выводит объекты JSON в консоль, но он не работает в PDF-файлах. Что мне нужно изменить, чтобы содержимое JSON отображалось в формате PDF
public getActBwaDataExport() {
const yearString = this.navService.year ? `${this.navService.year}` : `${new Date().getFullYear()}`;
console.log('Selected year:', yearString);
this.bwaService.getAllBWAMonthData(yearString).subscribe(
(resp: any) => {
const bwaMonth = resp.success ? resp.act_bwa : null;
const data = bwaMonth.actBwaResu<
const yearlyBwaResults = resp.act_bwa.yearlyActBwaResu<
if (null !== data amp;amp; data amp;amp; yearlyBwaResults) {
const bwaMonthData: string[] = [];
const bwaNames = _.uniq(data.map((d) => d.kagName)) as string[];
const bwaMonthDataObj = Object.values(bwaMonthData);
const dataObj = Object.values(data);
const ybrObj = Object.values(yearlyBwaResults);
this.mandantKagIds = _.uniq(data.map((d) => d.mandantKagId));
for (const n of bwaNames) {
bwaMonthData[n] = data.filter((d) => d.kagName === n);
if (bwaMonthData[n].length > 0) {
const row: any = { kagName: bwaMonthData[n][0].kagName, kagNumber: bwaMonthData[n][0].kagNumber, values: {}, mandantKagId: bwaMonthData[n][0].mandantKagId };
for (const item of bwaMonthData[n]) {
row.values[item.period] = this.transformAmount(item.amount);
}
const yrNameItem = yearlyBwaResults.find((yr) => yr.kagName === n);
row.values.currentYear = (yrNameItem amp;amp; yrNameItem !== null) ? this.transformAmount(yrNameItem.amount) : null;
const dbNrStr = `${bwaMonthData[n][0]['db-nr']}`;
row.highlight = (dbNrStr.length === 7);
console.log('row:', row);
this.renderRows.push(row);
}
}
this.data = this.renderRows;
} else {
console.log('There is no data available for this year!!!!');
}
);
}