zoukankan      html  css  js  c++  java
  • 取得excel有效信息

              //0/加入using Excel; 

              string strFileName = "test.xls";
                //1、判斷file this.Server.MapPath(strFileName)存在
                //2、取信息
                object missing = System.Reflection.Missing.Value;

                ApplicationClass appc = new ApplicationClass();//lauch excel application

                if (appc != null)
                {
                    //open excel file
                    if (appc.Application.Workbooks != null)
                    {
                        Workbook wb = appc.Application.Workbooks.Open(this.Server.MapPath(strFileName), missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

                        int srow = 2;
                        int erow = ws.UsedRange.Rows.Count;
                        int scolumn = 1;
                        int ecolumn = ws.UsedRange.Columns.Count;
                        for (int irow = srow; irow <= erow; irow++)
                        {
                            strValue += "Row" + (irow-1);
                            for (int icolu = scolumn; icolu <= ecolumn; icolu++)
                            {
                                strValue += " Cell" + icolu + ":" + ((Range)ws.Cells.get_Item(irow, icolu)).Value2.ToString();
                            }
                            strValue += "<br/>";
                        }
                        this.Response.Write(strValue);
                    }

                }
                appc.Quit();

                appc = null;

  • 相关阅读:
    列举面向对象中的特殊成员以及应用场景
    python中os和sys模块
    谈谈你对闭包的理解?
    Python面试题(练习一)
    logging模块的作用以及应用场景
    Python的垃圾回收机制
    Python的深浅copy
    rust 支持的CPU架构
    Rust 数据类型
    网站用https访问的问题
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1274652.html
Copyright © 2011-2022 走看看