zoukankan      html  css  js  c++  java
  • 读写EXCEL,操作网页DLL

    推荐一个很好的开源项目,用于C#读写EXCEL的,在http://npoi.codeplex.com/中下载

    例子(读取EXCEL到TABLE):

     using NPOI.HSSF.UserModel;
    using NPOI.SS.UserModel;      
    #region "得到数据的Datatable"
            DataTable Get_ExcelData(Stream fileContent)
            {
                HSSFWorkbook workbook = new HSSFWorkbook(fileContent);
                Sheet sheet = workbook.GetSheetAt(0);
    
                DataTable table = new DataTable();
    
                Row headerRow = sheet.GetRow(0);
                int cellCount = headerRow.LastCellNum;
    
                for (int i = headerRow.FirstCellNum; i < cellCount; i++)
                {
                    var objCell = headerRow.GetCell(i);
                    if (objCell != null)
                    {
                        DataColumn column = new DataColumn(objCell.StringCellValue);
                        table.Columns.Add(column);
                    }
                    else
                        break;
                }
    
                int rowCount = sheet.LastRowNum;
    
                for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
                {
                    Row row = sheet.GetRow(i);
                    DataRow dataRow = table.NewRow();
    
                    for (int j = row.FirstCellNum; j < table.Columns.Count; j++)
                    {
                        if (row.GetCell(j) != null)
                            dataRow[j] = row.GetCell(j).ToString();
                    }
    
                    table.Rows.Add(dataRow);
                }
    
                workbook = null;
                sheet = null;
    
                return table;
            }
            #endregion

    另外一个开源项目是用于C#操作HTML,下载地址:http://htmlagilitypack.codeplex.com/

    具体操作方法:http://blog.csdn.net/malimalihun/article/details/6683434

  • 相关阅读:
    layui
    JSON
    jQuery
    实例——模拟验证码
    实例——表格的相关操作:添加行,删除行,编辑单元格
    实例——省市区三级联动 & 还可以输入字符统计
    实例练习——轮播图 & 全选/全不选
    练习-计算器
    定时器 & 日期时间对象 & 正则
    ThinkPHP实现分页
  • 原文地址:https://www.cnblogs.com/Journey31/p/3107778.html
Copyright © 2011-2022 走看看