导入excel代码:
private void button1_Click_1(object sender, EventArgs e)
{
try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel File (.xls,.xlsx)|*.xls; *.xlsx";
openFileDialog.FilterIndex = 1;
openFileDialog.Multiselect = false;
DialogResult dResult = openFileDialog.ShowDialog();
if (dResult == DialogResult.OK)
{
System.IO.FileStream stream = new System.IO.FileStream(openFileDialog.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
sp.gcSpreadSheet1.OpenExcel(stream);
stream.Close();
MessageBox.Show("导入成功");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
导入前正常
导入后空白(excel文件并不是空白的)
|
|