c1FlexGrid控件导入excel文件如何将excel中sheet的内内全部显示
代码如下
// choose file
OpenFileDialog dlg = new OpenFileDialog();
dlg.DefaultExt = "xls";
dlg.FileName = "*.xls";
if (dlg.ShowDialog() != DialogResult.OK)
return;
// clear date source
c1FlexGrid1.DataSource = null;
string[] sheets = c1FlexGrid1.LoadExcelSheetNames(dlg.FileName);
Console.WriteLine("Found {0} sheets in this book.", sheets.Length);
foreach (string sheet in sheets)
{
Console.WriteLine("- {0}", sheet);
}
// load the first sheet in the book
FileFlags flags = (checkBox1.Checked) ? FileFlags.IncludeFixedCells : FileFlags.None;
c1FlexGrid1.LoadGrid(dlg.FileName, FileFormatEnum.Excel, flags);
dlg.RestoreDirectory = true;
运行之后的界面 |
|