How to delete header(titles of column, row) in excel ? My template is this, im making the excel vía an external button (not the toolbar from grid) :
function generarExcel(e) {
grid.showSpinner();
var excelExportProperties = {
fileName: "VentasRutaDiaria.xlsx"
};
grid.excelExport(excelExportProperties);
grid.excelExportComplete = () => {
grid.hideSpinner();
}
}
grid = new ej.grids.Grid({
dataSource: [],
//allowPaging: true,
height: 700,
enableInfiniteScrolling: true,
allowResizing: true,
pageSettings: { pageSize: 50 },
allowExcelExport: true,
//excelQueryCellInfo: exportQueryCellInfo,
//excelHeaderQueryCellInfo: exportQueryCellInfo,
allowFiltering: true,
filterSettings: { type: 'Excel' },
locale: 'es-MX',
//toolbar: ['ExcelExport'],
columns: [
{ field: 'fecha', headerText: 'Fecha', width: 100, format: 'dd/MM/yyyy', textAlign: 'Left', },
{ field: 'ruta', width: 140, headerText: 'Ruta', type: 'string', textAlign: 'Left', },
{ field: 'vendedor', width: 140, headerText: 'Vendedor', type: 'string', textAlign: 'Left', },
{ field: 'marcaNombre', width: 140, headerText: 'Marca', type: 'string', textAlign: 'Left', },
{ field: 'productoClasificacion', width: 200, headerText: 'Clasificación del producto', type: 'string', textAlign: 'Left', },
{ field: 'productoCodigo', width: 140, headerText: 'Código del producto', type: 'string', textAlign: 'Left', },
{ field: 'producto', width: 140, headerText: 'Descripción del producto', type: 'string', textAlign: 'Left', },
{ field: 'cajas', width: 140, headerText: 'Cajas físicas', type: 'number', format: 'N2', textAlign: 'Right', },
{ field: 'cajasUnidad', width: 140, headerText: 'Cajas unidad', type: 'number', format: 'N2', textAlign: 'Right', },
{ field: 'cajaOriginal', width: 140, headerText: 'Cajas originales', type: 'number', format: 'N2', textAlign: 'Right', },
{ field: 'precioUnitario', width: 140, headerText: 'Precio unitario', type: 'number', format: 'C2', textAlign: 'Right', },
{ field: 'importe', width: 140, headerText: 'Importe', type: 'number', format: 'C2', textAlign: 'Right', },
{ field: 'descuento', width: 140, headerText: 'Descuento', type: 'number', format: 'C2', textAlign: 'Right', },
{ field: 'impuesto1', width: 100, headerText: 'IVA', type: 'number', format: 'C2', textAlign: 'Right', },
{ field: 'impuesto3', width: 100, headerText: 'IEPS', type: 'number', format: 'C2', textAlign: 'Right', },
],
aggregates: [{
columns: [
{
type: 'Sum',
field: 'cajas',
format: 'N2',
footerTemplate: '${Sum}'
},
{
type: 'Sum',
field: 'cajasUnidad',
format: 'N2',
footerTemplate: '${Sum}'
},
{
type: 'Sum',
field: 'cajaOriginal',
format: 'N2',
footerTemplate: '${Sum}'
},
{
type: 'Sum',
field: 'importe',
format: 'C2',
footerTemplate: '${Sum}'
},
{
type: 'Sum',
field: 'descuento',
format: 'C2',
footerTemplate: '${Sum}'
},
{
type: 'Sum',
field: 'impuesto1',
format: 'C2',
footerTemplate: '${Sum}'
},
{
type: 'Sum',
field: 'impuesto3',
format: 'C2',
footerTemplate: '${Sum}',
cssClass: 'black'
},
]
},
]
});
Attachment: VentasRutaDiaria_87385680.rar
Hi FRANN LP,
Greetings from Syncfusion support.
Query: To delete row header in excelExport
In the Excel export, you want to remove the header text. Grid exports with the header to identify the specified field by default. so please share the purpose deleting the grid headers in excel exporting that will help to validate further.
Regards,
Mohammed Ansar.
Hello, thanks for the reply.
My clients wants the excel without the titles(Headers) of every column, they only want the information, is this possible?
Hi FRANN LP,
Query: To export excel without header in grid
Based on your query. you need to export the grid to Excel exporting without the grid’s header row. We have achieved your requirement using excelHeaderQueryCellInfo event and we passed the arguments with null value on header cells value.
|
let grid: Grid = new Grid({ dataSource: employeeDetails, allowExcelExport: true, allowPdfExport: true, excelHeaderQueryCellInfo: function (args) { args.cell.value = ''; }, toolbar: ['ExcelExport'], height: 350,
|
Sample: https://stackblitz.com/edit/wsyrwc?file=index.ts,index.html
Documentation: https://ej2.syncfusion.com/documentation/api/grid/#excelheaderquerycellinfo
Please get back to us if you need further assistance on this.
Regards,
Mohammed Ansar ,
Thanks for the response Mohammed Ansar Sathik Ali.
Is there a way to eliminate the first row from the excel? for example this :
excelHeaderQueryCellInfo: function (args) { args.cell.value = ''; },
Worked but, it gives me a null|empty value, but i dont want to have that extra rowHeader.Hi FRANN LP,
Grid exports with the header to identify the specified field by default.so we null the values .you want to delete the row. Currently we are working your query and we will update further details on May 25 2022.
until then we appreciate your patience.
Regards,
Mohammed Ansar ,
Hello, any update on this?
Hi FRANN LP,
Sorry for the inconvenience caused.
Currently we are validating with the excel team. We need some more time to achieve your requirement . We will update you the further details by June 3 2022.
We appreciate your patience until then.
Regards,
Mohammed Ansar
Hello
Mohammed Ansar Sathik Ali, any update on this ?
Hi FRANN LP,
Query: Delete row header in excelExport
Sorry for the inconvenience caused.
Based on your query, we have achieved that(“the remove grid header while excel exporting”) by utilizing the excelExportModule in the created event. We have fetched the whole rows data and delete first row(header row) using shift method then changed the index values of content rows. Since Now it is exporting Grid without header row.
|
created: function () { var processGridExportObject = this.excelExportModule.__proto__.processGridExport; this.excelExportModule.__proto__.processGridExport = function ( gobj, props, r ) { var rows = processGridExportObject.call(this, gobj, props, r); rows.shift(); rows.forEach((item, index) => { item.index = index + 1; }); return rows; }; },
|
Sample: https://stackblitz.com/edit/wsyrwc-jt8idd?file=index.ts,index.html
Please get back to us if you need further assistance on this.
Regards,
Mohammed Ansar
It worked! thanks so much for the help !!!
Hi FRANN LP,
Most welcome, please get back to us for further assistance.
Regards,
Swetha