I have a grid with numbers representing a type of error
the number is translated into a string e.g. 0 => No Error
When I do an excel export, I have numbers in the sheet
But when I do a CSV export I have strings
How can I have strings in my excel exports?
Sample here: https://plnkr.co/edit/LG7wMcPPp9cT7mGl?open=main.js&preview
<code>let gridApi;
const gridOptions = {
columnDefs: [
{
headerName: "Error Type",
field: "a",
valueFormatter: errorFormatter
}
],
rowData: createRowData(),
enableRangeSelection: true,
enableFillHandle: true,
};
function errorFormatter(params) {
if(params.value == null)
return "";
switch (params.value){
case 0:
return "No Error";
case 1:
return "Reading Error";
case 2:
return "Parsing Error";
}
}
function createRowData() {
const rowData = [];
for (let i = 0; i < 100; i++) {
rowData.push({
a: Math.floor(Math.random() * 2)
});
}
return rowData;
}
// setup the grid after the page has finished loading
document.addEventListener("DOMContentLoaded", function () {
const gridDiv = document.querySelector("#myGrid");
gridApi = agGrid.createGrid(gridDiv, gridOptions);
});
</code>
<code>let gridApi;
const gridOptions = {
columnDefs: [
{
headerName: "Error Type",
field: "a",
valueFormatter: errorFormatter
}
],
rowData: createRowData(),
enableRangeSelection: true,
enableFillHandle: true,
};
function errorFormatter(params) {
if(params.value == null)
return "";
switch (params.value){
case 0:
return "No Error";
case 1:
return "Reading Error";
case 2:
return "Parsing Error";
}
}
function createRowData() {
const rowData = [];
for (let i = 0; i < 100; i++) {
rowData.push({
a: Math.floor(Math.random() * 2)
});
}
return rowData;
}
// setup the grid after the page has finished loading
document.addEventListener("DOMContentLoaded", function () {
const gridDiv = document.querySelector("#myGrid");
gridApi = agGrid.createGrid(gridDiv, gridOptions);
});
</code>
let gridApi;
const gridOptions = {
columnDefs: [
{
headerName: "Error Type",
field: "a",
valueFormatter: errorFormatter
}
],
rowData: createRowData(),
enableRangeSelection: true,
enableFillHandle: true,
};
function errorFormatter(params) {
if(params.value == null)
return "";
switch (params.value){
case 0:
return "No Error";
case 1:
return "Reading Error";
case 2:
return "Parsing Error";
}
}
function createRowData() {
const rowData = [];
for (let i = 0; i < 100; i++) {
rowData.push({
a: Math.floor(Math.random() * 2)
});
}
return rowData;
}
// setup the grid after the page has finished loading
document.addEventListener("DOMContentLoaded", function () {
const gridDiv = document.querySelector("#myGrid");
gridApi = agGrid.createGrid(gridDiv, gridOptions);
});
0