TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Paul Rajs
NA
641
146.3k
How to Import/Download csv file in Jquery datatable
Dec 11 2020 5:28 AM
Dear Developers,
I am creating an application , in that i have to download jquery datatable as csv file.
Now am downloading as pdf file using the below code on GenericReportController.cs
C# Code
public
FileResult ExportCsv(
string
viewdataName,
string
fileName) {
var data =
""
;
data = TempData[viewdataName].ToString();
TempData[viewdataName] = data;
var dt = (DataTable) JsonConvert.DeserializeObject(data, (
typeof
(DataTable)));
if
(dt.Rows.Count > 0) {
dt.TableName = fileName.Replace(
'/'
,
'_'
);
using
(XLWorkbook wb =
new
XLWorkbook()) {
wb.Worksheets.Add(dt);
using
(MemoryStream stream =
new
MemoryStream()) {
wb.SaveAs(stream);
return
File(stream.ToArray(),
"application/octet-stream"
, fileName +
".csv"
);
}
}
}
else
return
null
;
}
How can I download to CSV file, kindly suggest me to I am done this task.
Regards
Paul.S
Reply
Answers (
1
)
Retrieve leads using weebhooks
Refer to an attribute within the serialization