Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Exception 尝试创建时,ExcelLibrary引发未经授权的访问异常_Exception_Oledb_Unauthorizedaccessexcepti_Excellibrary - Fatal编程技术网

Exception 尝试创建时,ExcelLibrary引发未经授权的访问异常

Exception 尝试创建时,ExcelLibrary引发未经授权的访问异常,exception,oledb,unauthorizedaccessexcepti,excellibrary,Exception,Oledb,Unauthorizedaccessexcepti,Excellibrary,正如标题所述,我的程序在尝试使用ExcelLibrary库创建Excel文件时抛出了一个UnauthorizedAccessException,这很奇怪,因为我的计算机对此没有任何限制。我的代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Common; using System.Drawing; using S

正如标题所述,我的程序在尝试使用ExcelLibrary库创建Excel文件时抛出了一个
UnauthorizedAccessException
,这很奇怪,因为我的计算机对此没有任何限制。我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Drawing;
using System.Linq;
using System.Data;
using System.Data.OleDb;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ExcelLibrary;
namespace ExcelTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private DataSet ds;
        private void Form1_Load(object sender, EventArgs e)
        {
            string cs = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=test1.mdb;";
            ds = new DataSet("New_DataSet");
            DataTable dt = new DataTable("New_DataTable");
            string[] x = new string[20];
            for (int i = 1; i < x.Length; i++)
            {
                x[i] = "a";
            }
            ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
            dt.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
            OleDbConnection con = new OleDbConnection(cs);
             con.Open();
            string sql = "SELECT * FROM personas;";
            OleDbCommand cmd = new OleDbCommand(sql, con);
            OleDbDataAdapter adptr = new OleDbDataAdapter();
            adptr.SelectCommand = cmd;
            adptr.Fill(dt);
            con.Close();
            ds.Tables.Add(dt);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ExcelLibrary.DataSetHelper.CreateWorkbook("C:\\Users\\spereyra\\Documents\\Visual Studio 2012\\Projects\\deleteme\\ExcelTest", ds);
            MessageBox.Show("creating excel");
        }
    }
    }

发现错误,我已指定文件的路径,但忘记键入文件名和扩展名: 而不是

ExcelLibrary.DataSetHelper.CreateWorkbook("C:\\Users\\spereyra\\Documents\\Visual Studio 2012\\Projects\\deleteme\\ExcelTest", ds);
                MessageBox.Show("creating excel");
我应该把

ExcelLibrary.DataSetHelper.CreateWorkbook("C:\\Users\\spereyra\\Documents\\Visual Studio 2012\\Projects\\deleteme\\ExcelTest\\myExcel.xls", ds);
                    MessageBox.Show("creating excel");

发现错误,我已指定文件的路径,但忘记键入文件名和扩展名: 而不是

ExcelLibrary.DataSetHelper.CreateWorkbook("C:\\Users\\spereyra\\Documents\\Visual Studio 2012\\Projects\\deleteme\\ExcelTest", ds);
                MessageBox.Show("creating excel");
我应该把

ExcelLibrary.DataSetHelper.CreateWorkbook("C:\\Users\\spereyra\\Documents\\Visual Studio 2012\\Projects\\deleteme\\ExcelTest\\myExcel.xls", ds);
                    MessageBox.Show("creating excel");