zoukankan      html  css  js  c++  java
  • c# .Net :Excel NPOI导入导出操作教程之读取Excel文件信息及输出

    c# .Net :Excel NPOI导入导出操作教程之读取Excel文件信息及输出


    using NPOI.HSSF.UserModel;
    using NPOI.SS.UserModel;
    using System;
    using System.Collections.Generic;
    using System.IO;


            //创建文件流对象
            using (FileStream filesrc = File.OpenRead(@"C:UsersAdministratorDesktop123.xls"))
            {
                //工作簿对象获取Excel内容
                IWorkbook workbook = new HSSFWorkbook(filesrc);

                for (int i = 0; i < workbook.NumberOfSheets; i++)
                {
                    ////获得工作簿里面的工作表
                    ISheet sheet = workbook.GetSheetAt(i);
                    Console.WriteLine(sheet.SheetName);
                    for (int r = 0; r <= sheet.LastRowNum; r++)
                    {
                        //获取每张表的信息
                        IRow row = sheet.GetRow(r);
                        for (int c = 0; c < row.LastCellNum; c++)
                        {
                            //获得每行中每个单元格信息
                            ICell cell = row.GetCell(c);
                            Console.WriteLine(cell.ToString() + "  |  ");
                        }
                    }

                }

    ————————分享End————————

  • 相关阅读:
    thinkphp3.2 无法加载模块
    php 使用 wangeditor3 图片上传
    nginx 配置 server
    oracle练手(一)
    Oracle练习(一)
    java运算符优先级
    数据库(mysql和oracle)
    java实现4种内部排序
    mysql-----分库分表
    NIO总结-----Buffer
  • 原文地址:https://www.cnblogs.com/jicheng/p/5961566.html
Copyright © 2011-2022 走看看