Комментарии:
I am using Visual studio 2022
I have this
Using workbook As XLWorkbook = New XLWorkbook
workbook.Worksheets.Add(Me.DataGridView1.DataSource, "NameOfSheetInExcel")
workbook.SaveAs(sfd.FileName)
and it says workbook is not defined. and and it does not know what XLWorkbook is. It suggests to change to ExcelWorkbook but that still does not work. I do have Imports Excel Interloop.
Please help
In my case i am not getting any search results for closedxml package in package manager. What should I do?
ОтветитьThanks a lot
I'm extremely grateful
Спасибо большое! Очень благодарен 😊
ОтветитьThank you so much!!!
ОтветитьC# Cdoe :)
using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "Excel Workbook|*.xlsx" })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
try
{
////This To get from gridview after meniplation
DataTable dt = new DataTable();
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
dt.Columns.Add(col.Name);
}
foreach (DataGridViewRow row in dataGridView1.Rows)
{
DataRow dRow = dt.NewRow();
foreach (DataGridViewCell cell in row.Cells)
{
dRow[cell.ColumnIndex] = cell.Value;
}
dt.Rows.Add(dRow);
}
using (XLWorkbook workbook = new XLWorkbook())
{
workbook.Worksheets.Add(dt,"Employee Report");
workbook.SaveAs(sfd.FileName);
}
MessageBox.Show("You have successfully exported your data to an excel file.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
hi, I'm using SQL server and when I print the excel file there is no data on it. Can you help me solve this, please?
Ответитьthe file downloaded is emty. whhhy ??
ОтветитьHi thks for this tutorial, but is not working to me, is saying that XLWorkbook is not defined
ОтветитьHi there, thanks for this tutorial. Just a quick question, how do we export data for filtered searched populating in the datagridview?
Ответитьplease what if the collumn of the datagridview are created manually what do we write inside the worksheets.add ()
ОтветитьFalto que exporte el titulo
ОтветитьHi Thanks for this tutorial, do you know any way to do this on .NET 5 thanks
ОтветитьHow if using mc access data base And export to excel ?
ОтветитьDid u stop publishing c#
ОтветитьFinally vb .net
Ответить