zoukankan      html  css  js  c++  java
  • 读取EXCEL

                using (FileStream fs = new FileStream(inputFile, FileMode.Open, FileAccess.Read))
                {
                    HSSFWorkbook workbook = new HSSFWorkbook(fs);
                    HSSFSheet sheet1 = (HSSFSheet)workbook.GetSheetAt(0);
    
    
                    using (FileStream csv = new FileStream(outputFile, FileMode.Create, FileAccess.Write))
                    {
                        using (StreamWriter write = new StreamWriter(csv, Encoding.UTF8))
                        {
                            for (int i = sheet1.FirstRowNum; i < sheet1.LastRowNum; i++)
                            {
                                HSSFRow row = (HSSFRow)sheet1.GetRow(i);
                                if (row == null)
                                    continue;
                                string content = "";
                                for (int j = row.FirstCellNum; j < row.LastCellNum; j++)
                                {
                                    HSSFCell cell = (HSSFCell)row.GetCell(j);
                                    if (cell == null)
                                        continue;
                                    content += cell.ToString().Replace("\n", "") + ",";
                                }
                                content = content.Substring(0, content.Length - 1);
                                write.WriteLine(content);
                            }
    
                        }
    
                    }
  • 相关阅读:
    php关联Apache和nginx
    /etc/profile
    snmp配置
    snmpwalk
    redis主从
    redis安装
    计算真实可用内存
    分类样本不均
    pandas apply 添加进度条
    linux 单次定时任务
  • 原文地址:https://www.cnblogs.com/zhhq/p/3022470.html
Copyright © 2011-2022 走看看