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 }
  • 相关阅读:
    10-索引优化分析(2)
    09-索引优化分析(1)
    08-优化 SQL 步骤
    XHR 框架与 Dojo( xhrGet,xhrPut,xhrDelete)
    Win7窗口操作
    SQLServer游标详解
    Graham算法—二维点集VC++实现
    SQlserver表连接
    字符数组中将空格移到最后java实现
    笛卡儿积的java实现
  • 原文地址:https://www.cnblogs.com/rumenren/p/3160814.html
Copyright © 2011-2022 走看看