马上加入IBC程序猿 各种源码随意下,各种教程随便看! 注册 每日签到 加入编程讨论群

C#教程 ASP.NET教程 C#视频教程程序源码享受不尽 C#技术求助 ASP.NET技术求助

【源码下载】 社群合作 申请版主 程序开发 【远程协助】 每天乐一乐 每日签到 【承接外包项目】 面试-葵花宝典下载

官方一群:

官方二群:

NPOI读取数据,创建filestream实例时总是出错

[复制链接]
查看4755 | 回复1 | 2013-12-7 21:20:57 | 显示全部楼层 |阅读模式
这是代码
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
using System.IO;
using NPOI.SS.UserModel;
namespace XLS实验
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
         
        private void button1_Click(object sender, EventArgs e)
        {
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                int[] bianhao = new int[225];
                string path = "";
                path = openFile.FileName;
                FileStream fs = File.Open(path,FileMode.Open);
                HSSFWorkbook myxls = new HSSFWorkbook(fs);
                ISheet mysheet = myxls.GetSheet("sheet1");
                StringBuilder sb = new StringBuilder("");
                for (int i = 0; i <= 225; i++)
                {
                    IRow row = mysheet.GetRow(i + 2);
                    ICell cell=row.GetCell(1);
                    bianhao[i] = (int)cell.NumericCellValue;
                    for(int j=0;j<=225;j++)
                    {
                        this.textBox1.Text+= bianhao[j].ToString();
                    }
                }
                fs.Close();
            }
             
             
        }
    }
}


每次到FileStream fs = File.Open(path,FileMode.Open);就会出错
我换过FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Read);   还是同样出错
ibcadmin | 2013-12-12 13:23:17 | 显示全部楼层
报的什么错
C#论坛 www.ibcibc.com IBC编程社区
C#
C#论坛
IBC编程社区
*滑块验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则