Hello Team, Please how do I prevent the edit and delete column from showing on the excel sheet.

Hello Team, Please how do I prevent the edit and delete column from showing on the excel sheet.

Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Jan 6, 2024, 5:37 PM
You can use the exportOptions property for each column. In your case, for the "Edit" and "Delete" columns, you can set the exportOptions property to { visible: false }.
In the exportOptions property for the Excel button, I specified the columns to be exported (0 to 6) and set the visible: false property for the "Edit" and "Delete" columns to exclude them from the export.
Emmmanuel FIADUFEPosted Jan 7, 2024, 5:22 PM
Thank you team,
it is working now, my appreciation goes to you all for your continuence support
Ali BenchaabanPosted Jan 6, 2024, 6:01 PM
Hello,
Could you give us more context about your query ?
Are you looking for a solution using Excel sheets ? Or it's used within a C# code ?
Regards,
BENCHAABAN Ali
Sachin SinghPosted Jan 6, 2024, 5:50 PM
use this it works fine
Emmmanuel FIADUFEPosted Jan 6, 2024, 11:12 AM
I export data from my DataTable into excel, it include the edit and delete column
$(document).ready(function () {
dataTable = $("#ItemInfo").DataTable({
"processing": false,
"serverSide": false,
"paging": true,
"destroy": true,
"order":[[0,'desc']],
pageLength: 25,
buttons: [
{ extend: 'excel', className: 'btn btn-dark rounded-0 ', text: ' Excel', title: 'Smart App' },
],
dom: '<"html5buttons"B>lTfgitp',
"columns": [
{ "data": "PCode" },
{ "data": "OrderDate" },
{ "data": "CategoryName" },
{ "data": "ProductName" },
{ "data": "UnitPrice" },
{ "data": "Quantity" },
{ "data": "TotalAmount" },
{
"data": null, "width": "50px", "render": function (data, type, full, meta) { return "Edit"; }
},
{
"data": "StockInHistoryId", "width": "50px", "render": function (data) { return "Delete"; }
},
],
"ajax": {
"url": "/Home/GetAllStockInHistory",
"type": "GET",
"dataSrc": "[]",
}
});
});