CodePudding user response:
Public static void Write (DictionaryData, int wsno=1)
{
System. Windows. Forms. SaveFileDialog saveDia=new System. Windows, Forms, SaveFileDialog ();
SaveDia. Filter="Excel | *. XLS";
SaveDia. Title="export to Excel file";
SaveDia. FileName=System. A DateTime. Now. ToString (" yyyyMMddHHmmss ");
If (saveDia ShowDialog ()==System. Windows. Forms. The DialogResult. OK
& & ! String. The Empty. Equals (saveDia FileName))
{
Using (ExcelPackage ep=new ExcelPackage (new to the FileInfo (saveDia. FileName)))
{
//ExcelWorksheet ws=ep. Workbook. Worksheets. The Add (" 1 ");
ExcelWorksheet ws=ep. Workbook. Worksheets [wsno];
Foreach (String p in the data. Keys)
{
Ws. Cells [p]. Value=https://bbs.csdn.net/topics/data [p].
}
Ep. The Save ();
}
}
}
CodePudding user response:
Very simple, baidu a handful