所属类别:技术博客
文章作者:kbxj406
特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!
1、//获取Execl中Sheet名字 private static ArrayList GetExecl(ref ArrayList ary, string Url) { Object refmissing = System.Reflection.Missing.Value; Excel._Application exc = new Excel.ApplicationClass(); exc.Visible = false; Excel.Workbooks workbooks = exc.Workbooks; workbooks._Open(Url, refmissing, refmissing, refmissing, refmissing, refmissing, refmissing, refmissing, refmissing, refmissing, refmissing, refmissing, refmissing); for (int i = 0; i < exc.Worksheets.Count; i++) { Excel.Worksheet sheet = (Excel.Worksheet)exc.Worksheets.get_Item(i + 1); ary.Add(sheet.Name.ToString()); } exc.Application.Quit(); return ary; }参考:http://community.csdn.net/Expert/topic/5049/5049541.xml?temp=.93540592、如果用以下函数,返回的列表已经根据sheet名称进行排列过了: 返回Excel表中的Sheets的名称 public string[] GetExcelSheets() { System.Data.DataTable dt = null; string[] res = null; try { //打开数据库链接 this.m_Conn.Open(); //将Sheets获取到表中 dt = this.m_Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (null != dt) { res = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { res[i] = dt.Rows[i]["TABLE_NAME"].ToString(); res[i] = res[i].Substring(0, res[i].Length - 1); } this.m_Conn.Close(); } else { res = null; } } catch (System.Data.OleDb.OleDbException e) { this.m_Conn.Close(); MessageBox.Show("获取Excel文件工作表失败", e.Message); //Wnd.ShowDialog(); return null; } return res; }发表于 @ 2006年09月28日 10:03:00评论(loading...AddFeedbackCountStack("1299452"))编辑旧一篇:Url里参数编码转换问题,用Server.UrlEncode(myname.text)来转换
相关信息· 串口连接设置超级终端管理交换机
· Sql Server:理解uniqueidentifier类型和NEWID()
· 令你的网页速度大大提高
· 亲密接触Discuz!NT之传承篇
93879
6061
