Tag: vsto

Close and open an excel workbook without flickering

I have been trying to achieve this from my application level addin but some how not able to get this right. Below are the steps I am trying to achieve on click of an application level addin button: Open an existing Excel file in current application. Do some refresh. After refresh close that (with Save […]

Excel VSTO workbook object returning empty

Excel VSTO add-in that puts a button in my ribbon. I have pinpointed where the issue lies, but I don’t know why this is giving me an error or how to fix it. Even more interesting, is that it works fine if I stay in the same instance of excel. I can run the add-in […]

Importing and Exporting Data into excel via clipboard

I want to import and export 1000+ cell data into and from excel via clipboard. Also the cell data is not in a symmetric grid and the solution needs this flexibility. How do I do this? From my research so far, the cell data should be in the form of tab delimited. use the StringBuilder […]

Tracking pivot table Filters in Excel using vsto c#

Could anybody suggest how to get the details of Filters that are applied on an Excel Pivot Table. Also from a set of Pivot Tables from current sheet, how to identify those pivot tables in which the filters are applied. Thanks in Advance..

How to store a column of data in excel to string in C#

I have a string[] member like this: private string[] mStrings = null; and code in the constructor like this: Excel.Application excelApp = new Excel.Application(); Excel.Workbook excelWorkBook = excelApp.Workbooks.Open(excel_file_path); Excel.Worksheet excelWorkSheet = (Excel.Worksheet)excelWorkBook.Sheets[2]; // I get the data from the second sheet I want to store data in column F to mStrings, so I wrote code […]

Renaming Excel Active Sheet (using VSTO) disables “Add” button of WorkBook

I am working on a Excel Add-In project using VSTO with C#. I am trying to rename the active worksheet with name input by user. The code is very simple Excel.Worksheet ws = (Excel.Worksheet)Globals.ThisAddIn.Application.ActiveSheet; ws.Name=”the new name of the Sheet”; However when the sheet gets renamed, the button to add new sheets gets disabled. If […]

Visual Basic, Excel VSTO: Set worksheet tab color

All, I hope this finds you well! I am currently converting some Visual C# code in a VSTO to Visual Basic and am running into trouble setting Tab.Color for a Worksheet. Currently, I’m doing this: Dim c As Color c = System.Drawing.Color.Blue Dim w As Excel.Worksheet w = Me.Application.Worksheets.Add() w.Tab.Color = c However, regardless of […]

Excel 2010 Workbook file not opening

I have created one Excel 2010 Workbook project in Visual Studio 2013. There are three sheets in this workbook project. Output of this project is “File_Name.xlsx”. It was working fine till Yesterday.Now when I hit run, somehow it just opens excel without any workbook in it. I repaired my Office still issue persists.I also tried […]

How to copy data into Excel range formatted as table and not lose table formatting

Does anyone know how to copy data into Excel via C# into a table range and not lose the table formatting? Everytime I copy data to the range, it loses the formatting that was set previously. private object[,] Get2DArrayData() { var obj = new object[2, 4]; obj[0, 0] = “Header1”; obj[0, 1] = “Header2”; obj[0, […]

Set format for all cells in Excel without selections, using C# and VSTO

Let’s assume that I want to set the format (“Text”, “Number”, “Percent”, “Date”, and so on) for all cells in the Excel worksheet. I now how to set the format for a single row or a single column. For example, the code setting the “Percent” format for all cells of the 3rd row looks as […]

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