zoukankan      html  css  js  c++  java
  • AX2009使用NPOI导入数据-方法二

    Excel2003-97

     1 static void NPOI_ImportExcel2003(Args _args)
     2 {
     3     System.IO.FileStream                file=new System.IO.FileStream("D:\test.xls", System.IO.FileMode::Open,System.IO.FileAccess::Read);
     4     NPOI.HSSF.UserModel.HSSFWorkbook    workBook= new NPOI.HSSF.UserModel.HSSFWorkbook(file);
     5     NPOI.SS.UserModel.ISheet            sheet=workBook.GetSheetAt(0);
     6     NPOI.SS.UserModel.IRow              row;
     7     NPOI.SS.UserModel.ICell             cell;
     8     int                                 i,j,t,rowCount,cellCount;
     9     ;
    10     t=timenow();
    11 
    12     rowCount=sheet.get_LastRowNum();
    13     for(i=0;i<rowCount;i++)
    14     {
    15         row=sheet.GetRow(i);
    16         cellCount=row.get_LastCellNum();
    17         for(j=0;j<cellCount;j++)
    18         {
    19            cell=row.GetCell(j);
    20            print cell.get_StringCellValue();
    21         }
    22     }
    23     file.Close();
    24 
    25     info(int2str(timenow()-t));
    26 }

    Excel2007

    跟2003-97版本差不多,只是workBook引用的class不一样(红色部分)

     1 static void NPOI_ImportExcel2007(Args _args)
     2 {
     3     System.IO.FileStream                file=new System.IO.FileStream("D:\test.xlsx", System.IO.FileMode::Open,System.IO.FileAccess::Read);
     4     NPOI.XSSF.UserModel.XSSFWorkbook    workBook= new NPOI.XSSF.UserModel.XSSFWorkbook(file);
     5     NPOI.SS.UserModel.ISheet            sheet=workBook.GetSheetAt(0);
     6     NPOI.SS.UserModel.IRow              row;
     7     NPOI.SS.UserModel.ICell             cell;
     8     int                                 i,j,t,rowCount,cellCount;
     9     ;
    10     t=timenow();
    11 
    12     rowCount=sheet.get_LastRowNum();
    13     for(i=0;i<rowCount;i++)
    14     {
    15         row=sheet.GetRow(i);
    16         cellCount=row.get_LastCellNum();
    17         for(j=0;j<cellCount;j++)
    18         {
    19            cell=row.GetCell(j);
    20            print cell.get_StringCellValue();
    21         }
    22     }
    23     file.Close();
    24 
    25     info(int2str(timenow()-t));
    26 }
  • 相关阅读:
    HDU 4734 F(x) 2013 ACM/ICPC 成都网络赛
    VC++中的头文件包含问题
    php调用com组件配置 以openoffice为例
    Android 进程和线程
    文件队列 QueueFile
    Android zip文件压缩解压缩
    Internet Explorer 11(IE11)无法切换第三方输入法
    非递归实现快速排序
    class_create()
    字符设备 register_chrdev_region()、alloc_chrdev_region() 和 register_chrdev()
  • 原文地址:https://www.cnblogs.com/rumenren/p/3160814.html
Copyright © 2011-2022 走看看