Click here to Skip to main content
15,888,908 members
Home / Discussions / C#
   

C#

 
AnswerRe: Problem with text editor - Plz Help( need badly) Pin
Christian Graus17-Aug-07 22:42
protectorChristian Graus17-Aug-07 22:42 
AnswerRe: Problem with text editor - Plz Help( need badly) Pin
Luc Pattyn18-Aug-07 0:22
sitebuilderLuc Pattyn18-Aug-07 0:22 
QuestionHow to Access Main Class in Inner Class ... Pin
Doug.Chen17-Aug-07 21:43
Doug.Chen17-Aug-07 21:43 
AnswerRe: How to Access Main Class in Inner Class ... Pin
Hessam Jalali17-Aug-07 22:00
Hessam Jalali17-Aug-07 22:00 
AnswerRe: How to Access Main Class in Inner Class ... Pin
Christian Graus17-Aug-07 22:44
protectorChristian Graus17-Aug-07 22:44 
AnswerRe: How to Access Main Class in Inner Class ... Pin
Luc Pattyn18-Aug-07 0:26
sitebuilderLuc Pattyn18-Aug-07 0:26 
Questiontool tip in Close box Pin
topksharma198217-Aug-07 21:16
topksharma198217-Aug-07 21:16 
QuestionNo overload for method 'Open' takes '13' arguments.... Pin
shafikshafik17-Aug-07 20:49
shafikshafik17-Aug-07 20:49 
dear sir,
i want read an excel file and open it to listview but now two exception throws would u help me.....its very urgent.

exceptions:
==============
1. No overload for method 'Open' takes '13' arguments
2. Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Excel.Range.get_Value(object)' or 'Excel.Range.set_Value(object, object)'



source code:
===============
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using System.Office.Interop.Excel;


//private Excel.Application ExcelObj = null;


namespace Project_test1
{

public partial class Form1 : Form
{

private Excel.Application ExcelObj = null;

public Form1()
{
// Initialize the Windows Components
InitializeComponent();
ExcelObj = new Excel.Application();
// See if the Excel Application Object was successfully constructed
if (ExcelObj == null)
{
MessageBox.Show("ERROR: EXCEL couldn't be started!");
System.Windows.Forms.Application.Exit();
}
// Make the Application Visible
ExcelObj.Visible = true;



}

string[] ConvertToStringArray(System.Array values)
{
// create a new string array
string[] theArray = new string[values.Length];
// loop through the 2-D System.Array and populate the 1-D String Array
for (int i = 1; i <= values.Length; i++)
{
if (values.GetValue(1, i) == null)
theArray[i - 1] = "";
else
theArray[i - 1] = (string)values.GetValue(1, i).ToString();
}
return theArray;
}


private void Form1_Load(object sender, EventArgs e)
{

}

private void btn_Click(object sender, EventArgs e)
{
// prepare open file dialog to only search for excel files (had trouble setting this in design view)
this.openFileDialog1.FileName = "*.xls";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
// Here is the call to Open a Workbook in Excel
// It uses most of the default values (except for the read-only which we set to true)
Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(openFileDialog1.FileName, 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true);
// get the collection of sheets in the workbook
Excel.Sheets sheets = theWorkbook.Worksheets;
// get the first and only worksheet from the collection of worksheets
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
// loop through 10 rows of the spreadsheet and place each row in the list view
for (int i = 1; i <= 3; i++)
{
Excel.Range range = worksheet.get_Range("A" + i.ToString(), "J" + i.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
string[] strArray = ConvertToStringArray(myvalues);
listView1.Items.Add(new ListViewItem(strArray));
}
}

}

i add :
=========
Microsoft Excel 9.0 Objects Library.
AnswerRe: No overload for method 'Open' takes '13' arguments.... Pin
Christian Graus17-Aug-07 20:57
protectorChristian Graus17-Aug-07 20:57 
AnswerRe: No overload for method 'Open' takes '13' arguments.... Pin
Luc Pattyn18-Aug-07 0:26
sitebuilderLuc Pattyn18-Aug-07 0:26 
QuestionImporting xsd Pin
dnlstffrd17-Aug-07 19:57
dnlstffrd17-Aug-07 19:57 
QuestionRe:Displaying child windows Pin
RameshwerE17-Aug-07 19:34
RameshwerE17-Aug-07 19:34 
AnswerRe:Displaying child windows Pin
Rocky#17-Aug-07 19:50
Rocky#17-Aug-07 19:50 
AnswerRe:Displaying child windows Pin
Christian Graus17-Aug-07 20:14
protectorChristian Graus17-Aug-07 20:14 
AnswerRe:Displaying child windows Pin
Doug.Chen17-Aug-07 21:54
Doug.Chen17-Aug-07 21:54 
QuestionRe:Displaying child windows Pin
Doug.Chen17-Aug-07 21:59
Doug.Chen17-Aug-07 21:59 
AnswerRe:Displaying child windows Pin
Hessam Jalali17-Aug-07 22:10
Hessam Jalali17-Aug-07 22:10 
Questionbinpath Pin
sima_m17-Aug-07 19:28
sima_m17-Aug-07 19:28 
AnswerRe: binpath Pin
Paul Conrad18-Aug-07 3:25
professionalPaul Conrad18-Aug-07 3:25 
QuestionDate Conversion Pin
Parvai17-Aug-07 19:27
Parvai17-Aug-07 19:27 
AnswerRe: Date Conversion Pin
Christian Graus17-Aug-07 20:19
protectorChristian Graus17-Aug-07 20:19 
AnswerRe: Date Conversion Pin
Luc Pattyn18-Aug-07 0:32
sitebuilderLuc Pattyn18-Aug-07 0:32 
AnswerRe: Date Conversion Pin
PIEBALDconsult18-Aug-07 10:05
mvePIEBALDconsult18-Aug-07 10:05 
Questionhow to send a complex message in msmq [modified] Pin
zencer17-Aug-07 18:43
zencer17-Aug-07 18:43 
Questioncomparing two versions of the same document side-by-side graphically Pin
vkponugoti17-Aug-07 16:28
vkponugoti17-Aug-07 16:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.