Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
[what's my wrong? and why my file excel don't create file?]
Đạt Lữ
7y
214
1
Reply
private
void
btnExportExcel_Click(
object
sender, EventArgs e)
{
string
filePath = GetFileNameToSave();
if
(
string
.IsNullOrEmpty(filePath))
{
return
;
}
pivotGrid.ExportToXlsx(filePath);
ActionNotifier.Information(
"Exported file Excel."
);
System.Diagnostics.Process.Start(filePath);
}
static
string
GetFileNameToSave()
{
string
fNameDefault = String.Format(
"{0}.{1}.xlsx"
,
"Export"
, DateTime.Now.ToString(
"yy.MM.dd_hh.mm"
));
using
(SaveFileDialog dlgSave =
new
SaveFileDialog { Title =
"Export Excel"
, Filter =
"Excel file |*.xlsx "
, FileName = fNameDefault })
{
dlgSave.OverwritePrompt =
true
;
dlgSave.RestoreDirectory =
true
;
if
(dlgSave.ShowDialog() != DialogResult.OK || !dlgSave.CheckPathExists)
return
null
;
dlgSave.AddExtension =
true
;
string
fileName = dlgSave.FileName.Trim();
if
(!fileName.EndsWith(
".xlsx"
))
fileName +=
".xlsx"
;
return
fileName;
}
}
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
How to track action of user on asp.net application !!
xamarin using Android application hide soft keyborad