从Windows应用程序C#中的sheet1和sheet2的excelsheet导入数据 [英] Import data from excelsheet for sheet1 and sheet2 in windows application C#

查看:200
本文介绍了从Windows应用程序C#中的sheet1和sheet2的excelsheet导入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<我想阅读同一工作簿中的工作表2和工作表1数据



但是第二个语句的显示错误如何(xl.Worksheet ws = (xl.Worksheet)wb.Sheets [1];)发生了错误的索引错误。



你能帮帮我吗?



我想读两张数据表,即Sheet1和Sheet2两个。



紧急请帮帮我。



我尝试了什么:



我试过这种方式



xl.Worksheet ws =(xl.Worksheet)wb .Sheets [1];

xl.Worksheet ws =(xl.Worksheet)wb.Sheets [2];

<I want to read the sheet 2 and sheet 1 data from same workbook

but any how its showing error for 2nd statement (xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1];) bad index error occured.

Can you help me out ??

I want to read both sheets data i.e Sheet1 and Sheet2 both.

Its urgent please help me out.

What I have tried:

I tried this way

xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1];
xl.Worksheet ws = (xl.Worksheet)wb.Sheets[2];

推荐答案

替换这个:

Replace this:
xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1];



with:


with:

Worksheet ws = (Worksheet)wb.Workssheets[1];


这篇关于从Windows应用程序C#中的sheet1和sheet2的excelsheet导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆