zhoushuang0426

在项目中会有导出模板功能,把现成的Excel模板导出去填写之后再进行导入,这里说说怎么导出模板:

模板存放位置:

点击导出模板按钮:

      private string currentPath = Path.GetFullPath(@"..\..\");

     /// <summary> /// 导出模板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void materialButton4_Click(object sender, EventArgs e) { string path = Path.Combine(currentPath, "Excel", "template", "XXX模板.xlsx"); try { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "excel97-2003文件(*.xls,*xlsx)|*.xls;*xlsx"; sfd.FileName = string.Format("XXX模板{0}", DateTime.Now.ToString("yyyyMMddhhmmss")); if (sfd.ShowDialog() == DialogResult.OK) { Console.WriteLine(sfd.FileName); File.Copy(path, sfd.FileName); MessageBox.Show("导出成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message+",出现异常exporttemplate"); } }

 

分类:

技术点:

相关文章:

  • 2021-06-01
  • 2021-02-19
  • 2021-11-14
  • 2021-09-17
  • 2021-04-02
  • 2021-12-05
  • 2021-11-02
  • 2021-11-02
猜你喜欢
  • 2021-12-31
  • 2021-09-21
  • 2021-10-01
  • 2021-05-08
  • 2021-11-05
  • 2021-11-07
  • 2021-04-27
相关资源
相似解决方案