i've got a problem with the import of Excel Worksheets into a summary Workbook. First i try to import the data as DataTable, using: `Dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); tableName = GetTableNames(Dt); com = new OleDbDataAdapter(SqlQuery(tableName[0]), conn); com.Fill(DtSet); Dt = DtSet.Tables[0];` works fine excep
我在将Excel工作表导入到摘要工作簿时遇到了问题。 首先,我尝试使用以下方式将数据导入为DataTable: `Dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); tableName = GetTableNames(Dt); com = new OleDbDataAdapter(SqlQuery(tableName[0]), conn); com.Fill(DtSet); Dt = DtSet.Tables[0];` 在将数据复制到新工作表之后,除了一些标题已经丢失的事实
I'm new to C# and Excel and I'm trying to copy data from one sheet (that is full of data) to a new one that is empty. I'm using NPOI and I've figured out a few things, but I have problems when adding the data. The second sheet is empty, so all the cells are null (please correct me if I'm wrong). When I try to copy data from the first sheet to the second, nothing happens: t
我是C#和Excel的新手,我试图将数据从一张表(充满数据)复制到一张空白的新表中。 我正在使用NPOI,我已经想出了一些事情,但是在添加数据时遇到了问题。 第二张纸是空的,所以所有的单元格都是空的(如果我错了,请纠正我)。 当我尝试将数据从第一张表复制到第二张时,没有任何反应:单元格没有填充。 using (FileStream fs = new FileStream(@"C:UsersMyDoc.xlsx", FileMode.Open, FileAccess.ReadWrite)) { XSSFWo
I'm trying to copy a worksheet from an existing Excel file to my current workbook. I have an Excel Add-in with the following code: string wsName = "template." + ((System.Windows.Forms.Button)sender).Tag + "." + ((System.Windows.Forms.Button)sender).Text; Microsoft.Office.Interop.Excel.Application x = new Microsoft.Office.Interop.Excel.Application(); x.Visible = fals
我试图将工作表从现有的Excel文件复制到当前的工作簿中。 我有以下代码的Excel加载项: string wsName = "template." + ((System.Windows.Forms.Button)sender).Tag + "." + ((System.Windows.Forms.Button)sender).Text; Microsoft.Office.Interop.Excel.Application x = new Microsoft.Office.Interop.Excel.Application(); x.Visible = false; x.ScreenUpdating = false; x.Workbooks.Ope
I'm writing a program in Visual Studio 2010 using C#, and I'm using the NPOI library. I'm trying to insert an image to the excel file. I tried 2 different methods and neither of them works. //Method 1 HSSFPatriarch patriarch = newSheet.CreateDrawingPatriarch() as HSSFPatriarch; HSSFClientAnchor anchor; var memoryStream = new MemoryStream(); System.Drawing.Image image = System.Dra
我正在使用C#编写Visual Studio 2010中的程序,并使用NPOI库。 我试图插入一个图像到Excel文件。 我尝试了两种不同的方法,它们都不起作用。 //Method 1 HSSFPatriarch patriarch = newSheet.CreateDrawingPatriarch() as HSSFPatriarch; HSSFClientAnchor anchor; var memoryStream = new MemoryStream(); System.Drawing.Image image = System.Drawing.Image.FromFile("image.jpeg"); image.Save(memoryStream, System.Dr
I've tried creating a new Excel file with NPOI and it works OK, reading (only) an Excel file is also OK. However now I want to open an existing Excel file and append some rows on it, it's crashed right at the code line of the NPOI.HSSF.UserModel.HSSFWorkbook constructor. Here is the code: using(FileStream fs = new FileStream(myFile, FileMode.Append)){ HSSFWorkbook wb = new HSSFWork
我试着用NPOI创建一个新的Excel文件,它工作正常,只读Excel文件也是可以的。 然而,现在我想打开一个现有的Excel文件并在其上添加一些行,它就在NPOI.HSSF.UserModel.HSSFWorkbook构造函数的代码行处崩溃了。 代码如下: using(FileStream fs = new FileStream(myFile, FileMode.Append)){ HSSFWorkbook wb = new HSSFWorkbook(fs); //<-- It is crashed right at here .... } 没有任何异常细节,它只是显示一个
I need to programmatically create an Excel spreadsheet with 3 worksheets. For Sheet1, I'm trying to Export a Gridview...with all its formatting...and doing it without using Http.Response, because that technique forces a file 'Save/Save As' requester box to pop up and that seems to halt all further code execution. If I can succeed in directly writing my Gridview to an Excel Workboo
我需要以编程方式创建一个包含3个工作表的Excel电子表格。 对于Sheet1,我试图导出一个Gridview ...以及它的所有格式......并且不使用Http.Response,因为该技术强制文件“保存/另存为”请求者框弹出,这似乎停止所有进一步的代码执行。 如果我可以直接将我的Gridview写入Excel工作簿,我应该能够继续我的编码例程,然后重新打开文件并以编程方式添加表格2和3。 这段代码的工作原理...有点'...差不多! private void Exp
我将在导出时使用2种方法保存我的excel文件,第一个保存为直接在服务器中,第二个保存对话框以让用户选择他们自己的位置,因此在这种情况下,将在每次导出中总共保存2个文件我可以直接保存到服务器中,但是如何在保存对话框中添加保存功能并将其导出到Excel代码中? protected void EXPORT_BUTTON_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Inter
我将在导出时使用2种方法保存我的excel文件,第一个保存为直接在服务器中,第二个保存对话框以让用户选择他们自己的位置,因此在这种情况下,将在每次导出中总共保存2个文件我可以直接保存到服务器中,但是如何在保存对话框中添加保存功能并将其导出到Excel代码中? protected void EXPORT_BUTTON_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Inter
I am getting this error Collection was modified; enumeration operation may not execute. I have 3 forms. These are the form closing events of all 3 I did some research and learnt that some from was modified/shown inturn causing this error Form1 private void btnExitl_Click(object sender, EventArgs e) { this.Close(); } private void frmPlant_FormClosing(object s
我得到这个错误集合被修改; 枚举操作可能不会执行。 我有3种形式。 这些是所有3的形式关闭事件,我做了一些研究,并了解到一些来自修改/显示的内容导致此错误 Form1中 private void btnExitl_Click(object sender, EventArgs e) { this.Close(); } private void frmPlant_FormClosing(object sender, FormClosingEventArgs e) { if (DataDirty) { if (Dial
I'm instantiating Excel interop objects in my project. I know that special effort is required to clean up those objects (see this question). Is there any automated way to verify that the cleanup was done properly? To elaborate, I'm aware that when cleanup is not done properly, Excel.exe may continue running after Application.Quit is called. However, it is not clear to me whether that
我在我的项目中实例化Excel互操作对象。 我知道清理这些对象需要特别的努力(见这个问题)。 有没有自动的方法来验证清理是否正确完成? 详细说明,我知道,如果清理工作不正确,Excel.exe可能会在调用Application.Quit后继续运行。 但是,我不清楚这是否是可靠的测试条件。 另外,由于延续的Excel.exe过程仅仅是真正的功能障碍的症状,如果存在这样的情况,似乎更可取的是使用更接近根本原因的测试条件。 当完成使用Exc
I have read the page How do I properly clean up Excel interop objects? but I am running into an issue I can't figure out. There is a situation where an Excel instance is embedded and my addin is present causing a hang. I've released all of the COM objects and tried the double GC collection and GC wait lines as suggested for VSTO. This code below works and doesn't hang. public st
我已阅读该页面如何正确清理Excel互操作对象? 但我遇到了一个我无法弄清楚的问题。 有一种情况是Excel实例被嵌入并且我的插件存在导致挂起。 我已经发布了所有的COM对象,并尝试使用VSTO建议的双GC收集和GC等待线。 下面的代码工作,并没有挂起。 public static string GetCustomProperty(dynamic document, string propertyName) { string returnVal = string.Empty; dynamic customProperties = document.CustomDocu