Tag: c#

Why is some of the colorization of cells not occurring, and is there a connection between that and the “Cannot perform runtime binding” err msg?

I’m getting the following err msg: This is occurring in this code: private bool GetContractForDescription(string desc) { int DESCRIPTION_COL_NUM = 2; int CONTRACT_COL_NUM = 7; bool contractVal = false; int rowsUsed = _xlBook.Worksheets[“PivotData”].UsedRange.Rows.Count; int colsUsed = _xlBook.Worksheets[“PivotData”].UsedRange.Columns.Count; string colsUsedAsAlpha ReportRunnerConstsAndUtils.GetExcelColumnName(colsUsed); string endRange = string.Format(“{0}{1}”, colsUsedAsAlpha, rowsUsed); Range sourceData = _xlBook.Worksheets[“PivotData”].Range[string.Format(“A2:{0}”, endRange)]; // This is blowing […]

Streamwriter adding in extra line breaks randomly when exporting from visual studio to csv c#

I have been trying for a while now to export a data table to csv in visual studio after datalogging. For some reason I get weird results when importing into excel whereas notepad is fine. It seems line breaks are being added in but at random points within the data. I have battling this for […]

Open Excel file usint Interop using C#

I have this code in C# y used to open a Excel file. Excel.Application oXL = new Excel.Application(); Excel._Workbook oWB; String filename = “C:\\plantilla2.xlsx”; oWB = oXL.Workbooks.Open(filename, 0, true, 5, “”, “”, true, Excel.XlPlatform.xlWindows, “\t”, false, false, 0, true, 1, 0); MessageBox.Show(“FIN”); This code worked fine two days ago. I have not changed anything and […]

How to parse multiple sheets in Excel to data-set by using open xml

I search lot about how to read and copy data in multiple Excel sheets to data-set using open XML. Only get how to parse single sheet excel to data table. I have a Excel file with multiple sheets. I want to take the data to data-set, so below I pasted the code for copying one […]

C# Conditional Formatting Pivot Table loses formula

I’m having problem with a Conditional Formatting with Pivot Table. I get the range of the pivot table, my code display the Traffic Light icons, but if i show the pivot table details (expand or collapse) in both ways, the icons dissapear. I saw that the Conditional formula changes when I do that, but i […]

Get data from ListObject not made from code

In a VSTO Workbook, I would like to get data from a ListObject made from Excel. So there is not such things like DataBinding in code. What I would like to do is something like that : var rows = ((DataTable)Globals.Feuil1.MyNamedListObject.DataSource).Rows Unfortunately, here DataSource is null because, of course, it is not bound.

how to auto adjust excel when dynamically generate from the c# code

When i click the download button, the excel will download based on the existing input. But it is not showing the content correctly. it has collapsed. I want to do this in a auto adjust rows and column when i download this.. My code here: using (MemoryStream mem = new MemoryStream()) { SpreadsheetDocument spreadSheet = […]

Getting a “Failed – Network Error” for downloads in chrome the first time. Resume succeeds

We have a simple data grid on our web page and we provided an “Export To Excel” functionality. IE and firefox work perfect. But in chrome, we get the “Failed – Network Error” in the horizontal bar (downloads panel) at the bottom of the page when we click the button. If I click on it […]

How do I change the user a C# service opens an excel application from?

I have an excel program that runs as soon as the excel file is opened. It’s a huge program, so I cannot just rewrite it in C#. The program uses network paths that my user has permissions to. In the ProjectInstaller in my service, I have set the Account as User, so I have to […]

How to Store a key and value in a cell using ExcelPackage C#

Am creating an Excel sheet with dropdown for each cell using ExcelPackage.Now i pass a value to list as 20-APSECE (i.e) StudentId-StudentName so that i can render both id and name while rendering the excel using c#. Is there any other way, that only StudentName should be visible in list of dropdown and should get […]

MS Excel Spreadsheet is the best Office Software, Excel VBA and Excel Formulas make Spreadsheet work faster.