I have a part of code which tries to export data (from database) to Excel. When I am trying to perform this task, it is generating this error: System.Runtime.InteropServices.COMException occurred Additional information: Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) Code which is generating this error: string ExcelFileName = RootFolder + [...] read more
I'm trying to create an Excel file from VB.net from my first time. I already added the Microsoft.Office.Excel reference, Import the Microsoft.Office.Interop Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet Dim misValue As Object [...] read more
I'm trying to deploy an application that works fine on my development pc and some other workstations. However, some users receive an error that I can't seem to grasp. The program is a C# dotNet app with Excel.Interop functionality (Office 2003). I seem to be getting a problem with 'indexes'. [...] read more
How do I get the default project creation directory from within a Visual Studio 2010 extension? By default this directory is: C:\Users\<username>\Documents\Visual Studio 2010\Projects I'm guessing this is done via the Tools->Options window, but I don't know how to get at this via the SDK. At first glance the following [...] read more
This code add a worksheet to my workbook in a VSTO excel workbook application via a ribbon: Globals.ThisWorkbook.Worksheets.Add(); Excel.Window window = e.Control.Context; Excel.Worksheet activeWorksheet =((Excel.Worksheet)window.Application.ActiveSheet); The added worksheet is also the active one (obviously). How can I get existing worksheets in workbook application - ideally by name? This gives me [...] read more
I am receiving Invalid Index COM exception when calling Excel.AddIns.Item[0]. Excel.AddIns.Count works all right, which returns 4. But I just don't understand why Excel.AddIns.Item[0] fails to return the first Excel.AddIn object. The API doesn't seem to say too much about it either. http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.addins.item read more
I have a problem with Excel worksheet. I am trying to create an Excel file with c#. This code works and runs correctly on my computer but in other computers get an error at last line: Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheetInvoice; Excel.Worksheet xlWorkSheetInvoiceLine; object misValue = System.Reflection.Missing.Value; xlApp = [...] read more
I am want to pass datetimepicker Value to Crystal report to show rows Between those date i am using this code private void button3_Click(object sender, EventArgs e) { DateTime d1 = Convert.ToDateTime(this.dateTimePicker1.Value.ToShortDateString()); DateTime d2 = Convert.ToDateTime(this.dateTimePicker2.Value.ToShortDateString()); RPT.rpt_all_bocket_transaction myReport = new RPT.rpt_all_bocket_transaction(); myReport.SetParameterValue("@D1",d1); myReport.SetParameterValue("@D2",d2); RPT.frm_rpt myForm = new RPT.frm_rpt(); myForm.crystalReportViewer1.ReportSource = [...] read more
I have a Excel version problem with an Windows Forms Tool. Microsoft.Office.Interop.Excel.Worksheet ws = myExcelWorkbook.Worksheets[3]; ws.Delete(); ws = myExcelWorkbook.Worksheets[3]; This works perfectly with Excel 2010 but throws the following Exception in > Excel 2013: "0x8002000B DISP_E_BADINDEX" read more
> Possible Duplicate: > How to run a C# .exe file on many computers? I have a problem with my executable file. I made in C# windows forms to convert from txt to excel. Then in debug i took exe file there. In my computer with .NET 40 and Excel [...] read more
I am trying to copy excel sharepoint data and manipulate it using powershell or python. I tried the below code for powershell $fromfile = "https://company.sharepoint.com/:x:/r/personal/username_domain_company_com/................. Changes.xlsx" $tofile = "C:\ExcelTest\NewExcel.xlsx" $webclient = New-Object System.Net.WebClient $webclient.UseDefaultCredentials = $true $webclient.DownloadFile($fromfile, $tofile) $Excel = New-Object -ComObject Excel.Application $Workbook = $Excel.Workbooks.Open($tofile) $Worksheet = $Workbook.Sheets.Item($WorksheetName) $Excel.Visible [...] read more
i am adding multiple sheets to excel but it shows the exception System.Runtime.InteropServices.COMException: 'Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))' . the exception occurs at Position: xlWorkBook.Sheets("105") Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet105 As Excel.Worksheet Dim xlWorkSheet120 As Excel.Worksheet Dim xlWorkSheet125 As Excel.Worksheet Dim xlWorkSheet600 As [...] read more
I am trying to make an app that will open an xlsx file for reading, and than read it and do some stuff with it. When I run my app, and click a button to load the file, I am getting this error: > Invalid Index. Exception from HRESULT: 0x8002000B [...] read more
I have made a crystal report in asp.net for web application. Some report open nicely. But sometimes it does not. It shows the following problem. > Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) > Description: An unhandled exception occurred during the execution of the > current web request. Please review [...] read more
I can not pass values to the report. This is my code: public void GLRPT() { try { ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("~/Rpts/G1.rpt"); rptH.Load(); string df = Session["fromdate"].ToString(); string dt = Session["todate"].ToString(); DateTime fromdate = DateTime.Parse(df); DateTime todate = DateTime.Parse(dt); rptH.SetParameterValue("?Date_From", fromdate); rptH.SetParameterValue("?Date_To", todate); rptH.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, [...] read more
I have an error when passing my TextBox value to my Crystal Report: System.Runtime.InteropServices.COMException(0x8002000B): Invalid index. (Exception from HRESULT: 0x8002000B(DIS_E_BADINDEX)) at CrystalDecisions.ReportAppServer.DataDefModel.FieldsClass.get_Item(Int32 Index) at CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions.get_Item(Int32 Index) at CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions.get_Item(String fieldName) at WindowsFormsApplication1.Form15.button1_Click(Object sender, EventArgs e) in ..\Form15.cs: line 134 this is my code for getting my entered values in my textboxes [...] read more
I'm trying to get an Excel file using BindToMoniker. For this question I'm starting with the no running instance of Excel (no workbooks open). It opens one Excel instance with two Excel windows shown. The one is entitled Excel and the other is titled with my workbook name. Neither of [...] read more
I can't seem to access the properties in Visual Studio's options programmatically. Specifically, I have an extension that I need to leverages TFS power tools. I would like to get the value of the folder where the Work Item Templates are stored. Going into the options they are stored at [...] read more
I've recently been revising a report we've been using for years in Crystal Reports 9, a Traveler which displays job information from JobBOSS. I have had a little experience in the past with customizing reports, and this time around I've learned a lot, however, one thing I need to do [...] read more
I used this code to pass a value from DatagridviewCell to Crystal Report FormulaField: CrystalReport6 objRpt6 = new CrystalReport6(); for (int i = 0; i < statistiqueDataGridView.RowCount; i++) { objRpt6.DataDefinition.FormulaFields["CodeBonLivraison11"].Text = "'" + statistiqueDataGridView.Rows[i].Cells[0].Value.ToString() + "'"; } But I get this error message: > Invalid index. (Exception from HRESULT: 0x8002000B [...] read more
I've been trying for a while to declare or to open a excel sheet in vb.net. I already read excel file in vb.net and other links but it doesn't work. I added Microsoft Excel 12.0 Object Library. I included: Imports Microsoft.VisualBasic Imports System.Net.Mime.MediaTypeNames Imports Microsoft.Office.Interop I want to declare / [...] read more
I've been trying to retrieve the locations of all the page breaks on a given Excel 2003 worksheet over COM. Here's an example of the kind of thing I'm trying to do: Excel::HPageBreaksPtr pHPageBreaks = pSheet->GetHPageBreaks(); long count = pHPageBreaks->Count; for (long i=0; i < count; ++i) { Excel::HPageBreakPtr pHPageBreak [...] read more
Dim xl As New Excel.Application Dim xlBook As Excel.Workbook = xl.Workbooks.Open(myExcelFileName) Dim xlSheet As Excel.Worksheet = xlBook.Sheets("Sheet1") So I have the above code that open excel file to perform some operation later, The problem is sme sheets contain space in there names for example "sheetx " And when trying to [...] read more
I have a Database Application in which it has multiple dataGridViews on the Form. I am able to successfully export a single grid view to an Excel sheet but I would I would like to export the grid to different Excel sheets in a single Excel file. I tried the [...] read more
I'm using VB.net in MS Visual Studio 2012 to create an add-in for Excel (2010, 2007). The add-in uses Excel's Styles to format reports. Rather than iterate through the Styles collection, I thought it would be easier to try getting a reference to my style by name and catch the [...] read more
Does anyone know how to add a column to an existing list object in Excel, one that has already got a data source bound to it from a SQL source? I just want to add another column with a formula in every cell for that column of data, to match [...] read more
I am trying to create an AddIn in Visual Studio 2010 like below: public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; EnvDTE80.Windows2 wins2obj; AddIn addinobj; object ctlobj = null; Window newWinobj; // A toolwindow must be connected to an add-in, [...] read more
I have the following code to open a workbook and keep just one sheet: //Get a new workbook. oWB = app.Workbooks.Add(Missing.Value); int len = oWB.Sheets.Count; for (int i = 1; i < len; i++) { ((Worksheet)oWB.Sheets[i]).Delete(); } oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oWB.ActiveSheet; This code has worked for many years in many client [...] read more
I want to split one worksheet which has a column named Diameter into many sheets according to the number of diameters found, in my case it is Column C in a Master Sheet, My code is Private Sub Splitter() Dim xl As New Excel.Application Dim wb As Excel.Workbook Dim Source [...] read more
I have a code which is working very well in VB.Net 2013 and the same code (Copy & Paste) is not working in VB.Net 2019? I receive error > Invalid Index (Exception from HRESULT: 0X8002000B (DISP_E_BADINDEX)) The Error only shows with this Line Destination = CType(wb.Sheets(Diameter), Excel.Worksheet) wb is a [...] read more
I am trying to automate the conditional format of a range and only accept three types of icons. The routine is in the click event of a button. The code works as long as the value of the variable is less than or equal to three, variables xl3arrows, xl3arrowsgray, xl3flags. [...] read more
I have a Visual Studio extension that gets the value and then sets a value to the Text Editor -> General -> Track Changes setting in the Options dialog. A code that was working fine with Visual Studio 2012-2017: DTE vsEnvironment = (DTE)GetService(typeof(DTE)); Property trackChangesProperty = vsEnvironment.Properties["TextEditor", "General"].Item("TrackChanges"); is throwing [...] read more
I am trying to delete named ranges from a bunch of excel files. Getting the following exception throws when the code is running: "Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))" Tried everything thing I could think of but excel instances just won't quit! Please see the code pasted below. Interop [...] read more
I am trying to open a csv file and copy the data from within it to paste it into a tab in an already constructed excel (2016) workbook. my problem appears to be accessing the csv file properly. Here is my code use utf8; use Cwd; use warnings; use strict; [...] read more
Good day. It may be a noob question but ow do you pass a parameter from controller to crystal reports? I am kinda new when it comes to crystal reports. Controller ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "Mtop.rpt")); SqlConnection cn = new SqlConnection("Data Source=test.tayabas.gov.ph;initial catalog=iVehicles;User ID=sa;Password=TEST@dm!n!@#$%;MultipleActiveResultSets=True;Application Name=EntityFramework;"); SqlCommand cmd = [...] read more
I am working on a method which exports data from two different C# lists into two excel worksheets in a single workbook using the following code Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing); Microsoft.Office.Interop.Excel._Worksheet worksheet1 = null; worksheet1 = (Microsoft.Office.Interop.Excel._Worksheet)workbook.Sheets["Sheet1"]; worksheet1 = (Microsoft.Office.Interop.Excel._Worksheet)workbook.ActiveSheet; for (int i = 1; [...] read more
Attempting to load two Excel workbooks side by side with C# using Excel interop. I've tried a variety of ways, but I have been unable to get this to work. I've gotten it to work with Word documents. Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application(); ExcelApp.Visible = true; Microsoft.Office.Interop.Excel.Workbook doc1 = ExcelApp.Workbooks.Open(fileToOpen.ToString()); [...] read more
I am trying to import multiple excel workbook and bind it to datagridview as shown below my problem is I want to get sheet name using index to make this method fixable I am getting error that says I tried zero index I am get error too Invalid index. (Exception [...] read more
I am using the Powershell script to load data from about 5 Excel sheets (as a sample) from column A to AL. In reality, I have 100 Excel Sheets with 25 Tabs in each file. I have used the link How to use powershell to copy several excel worksheets and [...] read more
I am trying to delete excel sheets using for loop except selected sheet by User using Dropdown menu in asp.net web application. So, I have written a code in c#. int index = DropDownList1.SelectedIndex; int max = DropDownList1.Items.Count; int i=3; for (i=1; i <= max; i++) { if (i != [...] read more
I have a crystal report in my project. Whenever I am trying to open that page, This exception appear. > Crystal Report: Invalid index. (Exception from HRESULT: 0x8002000B > (DISP_E_BADINDEX)) In my Crystal Report, I have a Parameter Fields named isEffective (Boolean type). When I run the program and the [...] read more
I am trying to create some Excel sheets and then edit them. On Windows 8 it works as expected but when it is ran on Windows 10 it does not work. It breaks at xlWorkSheetEvt = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(sheetIndex); I get an COM exception that says there is a Index error(Exception from [...] read more
I am facing issue with excel reports during creation of two excel sheets ine one workbook using vb.net, I was using Microsoft Excel 2007 for report generation it was good but unfortunately I need to uninstall all Microsoft Office Components and then I installed WPS office.Then this problem arise during [...] read more
I'm working with VB2010 C# and CR13. I've created a report with empty parameter fields that I'll fill during runtime using the texts that the user will enter on multiple text boxes. I've created a dictionary that contains the parameter name as the key and the text as value. Dictionary<String, [...] read more
I have an application that displays certain database data, and includes a function to save that data to an excel workbook on request using the Microsoft.Office.Interop.Excel assembly. One of my users reports the following error when trying to save to an excel workbook: System.Runtime.InteropServices.COMException (0x8002000B): Invalid index. (Exception from HRESULT: [...] read more
I have problem with crystal report. This is the scenario. I want to print to printer from vb.net --> crystal Report --> Printer. There is one blank field called DOType. When i run the program, i want to print with 1 Original (blank field called DOType was changed into "ORIGINAL") [...] read more
need your help again! This Script doesn't work. It works for the first 3 Sheets, but doesn't work for the last one. If I switch the itemnumber (eg. 3->4 and 4->3) the new 3 works and the new 4 does not. Is this some sort of bug? Or am I [...] read more
I have a workbook that consists of 6 worksheets. I want to save sheet 2 & 3 With Excel .SheetsInNewWorkbook = 6 .Workbooks.Add() .... .Worksheets(2).Copy() filename = "1.txt" .ActiveWorkbook.SaveAs(filename, -4158) .Worksheets(3).Copy() filename = "2.txt" .ActiveWorkbook.SaveAs(filename, -4158) End With Upon copying the 2nd time, my application crash and return this error: [...] read more
Edit: Ignore - this is actually behaving this way because of some code outside the scope of this script. My mistake. I just submitted a request to close this post. I have a simple PowerShell script that is supposed to delete the first line from an Excel .xls file. My [...] read more
this happens in visual studio 2012 when pressing Ctrl-C on any text or code. it started happening after i installed Web Essentials Extension (although i don't think it is causing it)... even after removing it the error did not disappear. any help is appreciated. thanks. read more
i have a text box in the front end i want to display this textBox value along with my data table in CRYSTAL REPORT VIEWER. I have displayed data table value successfully , but found some hurdles to display textBox values. I am using Web Application(c#). Pls Help.. Thanks in [...] read more
I'm getting an error when I'm exporting Excel to C#, I can't find where my code is wrong and the solution for my problem Error : > An unhandled exception of type 'System.Runtime.InteropServices.COMException' > occurred in GestãoSI.exe > > Additional information: Índice inválido. (Excepção de HRESULT: 0x8002000B > (DISP_E_BADINDEX)) The [...] read more
I am exporting dataset to Excel. When trying with 3 Excel sheets, it is working fine. But if I try with a fourth sheet, it shows this exception. exception HREsult 0x8002000b disp_e_badindex Is there any answer for this? read more
I was wondering if you have experienced this vague issue when trying to copy a text in visual studio.net 2010 SP1: > Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) I've got Git Extensions and NuGet add-ons installed. I've also tried opening vs.net running in administrator mode. Was wondering if anybody [...] read more
I am trying to pass 2 values that are generated from C# passed to MS SQL stored procedure through Crystal reports so far i have this code string username = Context.User.Identity.Name; string date = DateTime.Now.ToShortDateString() ; ReportDocument crystalReport = new ReportDocument(); crystalReport.Load(Server.MapPath(@"..\admin\CrystalReport1.rpt")); crystalReport.SetParameterValue("@Username", username); crystalReport.SetParameterValue("@Date", date); crystalReport.SetDatabaseLogon("", "", @"dennislaptop-pc\SQLEXPRESS", "healthylifestyledb"); [...] read more
Code # get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # open Excel file my $Book = $Excel->WorkBooks->Open($file); # select worksheet number. Default is 1 (you can also select a worksheet by name) print "worksheet $worksheet\n"; my $Sheet = $Book->Worksheets($worksheet); where $worksheet is [...] read more
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception saying HRESULT: 0x8002000B (DISP_E_BADINDEX)) if I skip this line, the same error eccurs here: rd.PrintOptions.ApplyPageMargins(config) Did anyone have this problem before? thanks! read more
I want to split worksheets with Diameter Criteria in Column C in a Master Sheet, My code is Private Sub Splitter() Dim xl As New Excel.Application Dim wb As Excel.Workbook Dim Source As Excel.Worksheet Dim Destination As Excel.Worksheet Dim SourceRow As Long Dim Lastrow As Long Dim DestinationRow As Long [...] read more