zoukankan      html  css  js  c++  java
  • C#写入excel和txt

    写入txt:           

                 string path = Server.MapPath("~/") + "\Content\删除记录.txt";           

                 string w = DateTime.Now.ToString() + "----" + zfry.userid + "----" + zfry.username;
                w += "----" + zfry.ssqmc + "----" + zfry.bmmc + "----" + qymc + "----" + qydz;
                StreamWriter sw =System.IO.File.AppendText(path);
                sw.WriteLine(w);
                sw.Close();

    写入excel:

                string path = Server.MapPath("~/") + "\Content\删除记录.txt";
                HSSFWorkbook hssfWorkbook = new HSSFWorkbook(new FileStream(path, FileMode.Open));
                HSSFSheet sheet = (HSSFSheet)hssfWorkbook.GetSheetAt(0);
                int i = sheet.LastRowNum;
                HSSFRow row = (HSSFRow)sheet.CreateRow(i+1);
                row.CreateCell(0).SetCellValue(DateTime.Now.ToString());
                FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                hssfWorkbook.Write(fs);

  • 相关阅读:
    go chapter 4
    go chapter 3
    ETCD相关介绍--整体概念及原理方面
    go chapter 2
    go chapter 1
    使用kubeadm搭建kubernetes1.10集群 Posted on April 14, 2018
    单用户passwd修改root密码没反应
    is not in the sudoers file解决方案
    版本更换,开始学习鸟哥的私房菜
    ubuntu 常见命令
  • 原文地址:https://www.cnblogs.com/forthelichking/p/4193997.html
Copyright © 2011-2022 走看看