Sorry I think I’m still not understanding, I’m putting a snippet of code to help the question
private build() {
const sheet = this.workbook.getActiveSheet();
sheet.deleteRows(0, sheet.getRowCount());
sheet.deleteColumns(0, sheet.getColumnCount());
this.workbook.suspendPaint();
this.workbook.suspendEvent();
this.colunas = [
{
name: 'metadata',
displayName: '',
width: 0,
visible: false,
resizable: false,
value: function (item: PremissaDetailDTO) {
return JSON.stringify(item);
},
},
{
name: 'checkbox',
displayName: '',
width: 50,
visible: true,
resizable: false,
cellType: new GC.Spread.Sheets.CellTypes.CheckBox(),
},
{
name: 'premissa',
displayName: 'Premissa',
width: 200,
visible: true,
resizable: false,
value: function (item: PremissaDetailDTO) {
return item.nome;
},
},
{
name: 'empresa',
displayName: 'Empresa',
width: 0,
visible: false,
resizable: false,
value: function (item: PremissaDetailDTO) {
return item.empresa.nome;
},
},
{
name: 'cc',
displayName: 'Centro de Custo',
width: 0,
visible: false,
resizable: false,
value: function (item: PremissaDetailDTO) {
return item.centroCusto ? item.centroCusto.centroCusto : '';
},
},
{
name: 'unidade',
displayName: 'Unidade',
width: 0,
visible: false,
resizable: false,
value: function (item: PremissaDetailDTO) {
return item.unidadeDeMedida;
},
},
{
name: 'moeda',
displayName: 'Moeda',
width: 50,
visible: false,
resizable: false,
value: function (item: PremissaDetailDTO) {
return item.moeda.nomeMoeda;
},
},
];
this.colunas.push(...this.construirColunaValores());
this.workbook.resumeEvent();
this.workbook.resumePaint();
this.workbook.refresh();
}
private construirColunaValores(): GC.Spread.Sheets.IColumn[] {
....
//meses is a string array
return meses.map((data) => {
return {
name: 'mes',
displayName: data,
width: 0,
visible: true,
resizable: false,
// the function extractValorDaPremissa returns a string value from the parameters
value: (item: PremissaDetailDTO) => this.extrairValorDaPremissa(item, data),
};
});
}
Inside the “item” contains a list of values so I need to use the function