excel-interop

How to mix Excel Interop with ClosedXml: styles

有些话、适合烂在心里 提交于 2021-02-10 06:54:19
问题 I am trying to achieve the following in an Excel VSTO add-in: Copying/applying cell formatting from the original version of an Excel file. Reason: while processing Excel files, we occasionally need to change the style/coloring of a file in order to be able to process certain cells only. After the file has been processed, we need to restore the original cell formats. For that purpose, I wrote a VSTO add-in. It reads the orignal file, iterates over all used cells and applies the formatting of

Microsoft.Office.Interop.Excel PrintOut Throws Error

限于喜欢 提交于 2021-02-08 06:57:22
问题 I'm using Microsoft.Office.Interop.Excel in a .Net Framework 4.5 Windows Service project on my 64bit Windows 7 desktop workstation and everything appears to be working except the PageSetup properties and more importantly the PrintOut method of the Worksheet object. Here's the code: Microsoft.Office.Interop.Excel.Application ExcelApp = null; Microsoft.Office.Interop.Excel.Workbook WBook = new Microsoft.Office.Interop.Excel.Workbook; Microsoft.Office.Interop.Excel.Worksheet WSheet = new

How to make an XLAM UDF call portable?

北战南征 提交于 2021-02-07 10:30:19
问题 It seems that when I call a UDF in an XLAM file, the path to the XLAM file is embedded in the spreadsheet. When I open the spreadsheet from another machine (which has the same XLAM add-in installed, just installed to a different path) then Excel complains "This workbook contains links to other data sources..." This doesn't seem to be a problem with UDFs in XLLs. Is there a way around this? 回答1: This behaviour is a consequence of the way Addin UDFs are implemented in Excel. There are 3

Save file as PDF/A using Office.Interop.Excel

二次信任 提交于 2021-02-07 09:20:40
问题 How can I export an Excel spreadsheet to PDF/ A (ISO 19005-1)? EDIT: I'm asking for PDF/A, and not plain old PDF 1.5 as it exports by default. I've even emphasized the A in my original question. I can already export Word and PowerPoint documents to PDF/A, using the ExportAsFixedFormat() function, since the Word and PowerPoint functions both have an optional UseISO19005_1 parameter, but the Excel version is very different, and is missing lots of parameters. I can't seem to find any way to

Save file as PDF/A using Office.Interop.Excel

淺唱寂寞╮ 提交于 2021-02-07 09:20:31
问题 How can I export an Excel spreadsheet to PDF/ A (ISO 19005-1)? EDIT: I'm asking for PDF/A, and not plain old PDF 1.5 as it exports by default. I've even emphasized the A in my original question. I can already export Word and PowerPoint documents to PDF/A, using the ExportAsFixedFormat() function, since the Word and PowerPoint functions both have an optional UseISO19005_1 parameter, but the Excel version is very different, and is missing lots of parameters. I can't seem to find any way to

How to update PivotTable data source using C#?

核能气质少年 提交于 2021-02-07 06:18:31
问题 I would like to know how to update an existing pivot table data source. I am using Microsoft.Office.Interop.Excel and targeting users with Excel 2010. I am currently able to refresh the pivot table which works fine, however when more rows are added I want to include these rows in the pivot table data source. For example, the pivot table data source when viewed in Excel is DataSourceWorksheet!$A$2:$U$26 and I would like it to be changed to DataSourceWorksheet!$A$2:$U$86 (60 more rows) after my

C# - Excel - How to delete visible rows after AutoFilter?

十年热恋 提交于 2021-01-29 18:00:40
问题 I´m working on a little commandline tool to extract some data from an excel sheet. I want to delete all rows which are visible after applying an AutoFilter. Unfortunately, I just don´t know how to continue. After some searching, I did not find a working answer for me. Here is what I´ve got so far: oXL = new Excel.Application(); oXL.Visible = false; oWB = oXL.Workbooks.Open(source); oXS = (Excel.Worksheet)oWB.Sheets[1]; Excel.Range filter = oXS.UsedRange; filter.AutoFilter(8, "<>text to filter

Formating programmatically Excel cells from Scientific numeric to Text with C#

北城余情 提交于 2021-01-29 12:20:50
问题 I'm facing a problem after extracting data from my sqlServer dataBase to my Excel worksheet using Microsoft.Office.Interop.Excel reference. Numeric data are displayed in a scientific numeric format, instead of being displayed in a text format. I tried to format my cell this way, but still doesn't work : Microsoft.Office.Interop.Excel.Range cell= (Range) worksheet.Cells[rowNum, fieldNum]; cell.NumberFormat="@"; I tried even to set my cells format in my Input Excel file; which i'm actually

How to merge Worksheets from Multiple Workbooks into New WorkBook

给你一囗甜甜゛ 提交于 2021-01-29 09:11:28
问题 I want to merge data from multiple worksheets of multiple workbooks. For example, I have multiple Workbooks with multiple worksheets. So consider I want to merge data from "Worksheet1" of "WorkBook1" and data from "Worksheet2" of "Workbook2" and respectively into "NewWorkSheet" of New "WorkBook". I want to do this in a way that data is inserted into "NewWorkSheet" one below the other, like the first 20 rows from "Worksheet1" then next 20 from "Worksheet2" and so on... I could merge into a new

C# Excel Interop — How to check if a single cell in a range has cell borders?

空扰寡人 提交于 2021-01-28 10:52:43
问题 I am currently writing a C# application to parse excel worksheets. I have these loops, which iterate through every cell in the worksheet and print their values to the console: for (int i = 1; i <= excelRange.Height; i++) { for (int j = 1; j <= excelRange.Width; j++) { if (j == 1) Console.Write("\r\n"); if (excelRange.Cells[i, j] != null && excelRange.Cells[i, j].Value2 != null) if (excelRange.Cells[i, j].Value2.ToString() == "-2146826265") { Console.Write("\t"); } else { Console.Write