【发布时间】:2018-05-15 10:17:38
【问题描述】:
Microsoft.Office.Interop.Excel.Application xlApp;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(Type.Missing);
xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
int i = 0;
int j = 0;
if (dgvSearchStudFees.Visible == true)
{
for (i = 0; i <= dgvSearchStudFees.RowCount - 1; i++)
{
for (j = 0; j <= dgvSearchStudFees.ColumnCount - 1; j++)
{
DataGridViewCell cell = dgvSearchStudFees[j, i];
xlWorkSheet.Cells[i + 1, j + 1] = cell.Value;
}
}
var savefiledialog = new SaveFileDialog();
savefiledialog.FileName = "Atharva ExcelSheet";
savefiledialog.DefaultExt = ".xlsx";
if (savefiledialog.ShowDialog()=DialogResult.OK) // here I m getting an error "The left-hand side of an assignment must be a variable, property or indexer" Don't know what is wrong. Same as above If statement. its a code for exporting the Data Grid View data to Microsoft excel. I tried doing this code but still I don't understand why this error occurs.
{
xlWorkBook.SaveAs(savefiledialog.FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
xlApp.Quit();
}
请帮我处理这段代码。
【问题讨论】:
-
==>==.... -
应该是 == 不是 =
标签: c#