Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
Questionabout Device info [modified] Pin
vinay_K10-Sep-08 1:03
vinay_K10-Sep-08 1:03 
QuestionRe: about Device info Pin
Harvey Saayman10-Sep-08 1:40
Harvey Saayman10-Sep-08 1:40 
AnswerRe: about Device info Pin
vinay_K10-Sep-08 1:53
vinay_K10-Sep-08 1:53 
AnswerIsn't this the same question... Pin
leckey10-Sep-08 3:13
leckey10-Sep-08 3:13 
Questionprotection with rsa Pin
arminj10-Sep-08 1:00
arminj10-Sep-08 1:00 
AnswerRe: protection with rsa Pin
leppie10-Sep-08 1:13
leppie10-Sep-08 1:13 
GeneralRe: protection with rsa Pin
arminj11-Sep-08 10:51
arminj11-Sep-08 10:51 
Questionexcel open error "no overload for method Open takes 13 arguements" Pin
g_amol10-Sep-08 0:45
g_amol10-Sep-08 0:45 
I Use following code for Excel to List view entry




using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;



public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

ExcelObj = new Excel.Application();

if (ExcelObj == null)
{
MessageBox.Show("ERROR: EXCEL couldn't be started!");
System.Windows.Forms.Application.Exit();
}

object val = new object();
ExcelObj.Visible = true;

}

string[] ConvertToStringArray(System.Array values)
{
string[] theArray = new string[values.Length];
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;
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5,
this.columnHeader6,
this.columnHeader7,
this.columnHeader8,
this.columnHeader9,
this.columnHeader10});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(26, 43);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(536, 240);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "LastName";
this.columnHeader1.Width = 98;
//
// columnHeader2
//
this.columnHeader2.Text = "FirstName";
this.columnHeader2.Width = 93;
//
// columnHeader3
//
this.columnHeader3.Text = "Company";
this.columnHeader3.Width = 83;
//
// columnHeader4
//
this.columnHeader4.Text = "Address";
this.columnHeader4.Width = 73;
//
// columnHeader5
//
this.columnHeader5.Text = "City";
this.columnHeader5.Width = 71;
//
// columnHeader6
//
this.columnHeader6.Text = "State";
this.columnHeader6.Width = 67;
//
// columnHeader7
//
this.columnHeader7.Text = "Zip";
//
// columnHeader8
//
this.columnHeader8.Text = "Country";
//
// columnHeader9
//
this.columnHeader9.Text = "E-mail";
//
// columnHeader10
//
this.columnHeader10.Text = "Phone";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "File";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Open...";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// openFileDialog1
//
this.openFileDialog1.DefaultExt = "*.xls";
this.openFileDialog1.Filter = "Excel File (*.xls) | All Files (*.*) ||";
this.openFileDialog1.Title = "Choose an Excel File";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(584, 341);
this.Controls.Add(this.listView1);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Reading an Excel Spreadsheet";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void menuItem2_Click(object sender, System.EventArgs e)
{
this.openFileDialog1.FileName = "*.xls";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{


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);

for (int i = 1; i <= 10; 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));
}
}
}
}
}


ERROR:
Error 1 No overload for method 'Open' takes '13' arguments
Error 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)


Can Any One Give Me Solution Please
AnswerRe: excel open error "no overload for method Open takes 13 arguements" Pin
Giorgi Dalakishvili10-Sep-08 0:54
mentorGiorgi Dalakishvili10-Sep-08 0:54 
AnswerRe: excel open error "no overload for method Open takes 13 arguements" Pin
leppie10-Sep-08 0:55
leppie10-Sep-08 0:55 
Questionwhat is method group? Pin
George_George10-Sep-08 0:42
George_George10-Sep-08 0:42 
AnswerRe: what is method group? Pin
g_amol10-Sep-08 0:53
g_amol10-Sep-08 0:53 
GeneralRe: what is method group? Pin
leppie10-Sep-08 0:57
leppie10-Sep-08 0:57 
GeneralRe: what is method group? Pin
George_George10-Sep-08 1:03
George_George10-Sep-08 1:03 
GeneralRe: what is method group? Pin
J4amieC10-Sep-08 1:20
J4amieC10-Sep-08 1:20 
GeneralRe: what is method group? Pin
George_George10-Sep-08 1:28
George_George10-Sep-08 1:28 
AnswerRe: what is method group? Pin
leppie10-Sep-08 0:53
leppie10-Sep-08 0:53 
GeneralRe: what is method group? Pin
George_George10-Sep-08 1:05
George_George10-Sep-08 1:05 
GeneralRe: what is method group? Pin
leppie10-Sep-08 1:09
leppie10-Sep-08 1:09 
GeneralRe: what is method group? Pin
George_George10-Sep-08 1:12
George_George10-Sep-08 1:12 
GeneralRe: what is method group? Pin
leppie10-Sep-08 1:16
leppie10-Sep-08 1:16 
GeneralRe: what is method group? Pin
George_George10-Sep-08 1:27
George_George10-Sep-08 1:27 
GeneralRe: what is method group? Pin
Daniel Grunwald10-Sep-08 1:53
Daniel Grunwald10-Sep-08 1:53 
GeneralRe: what is method group? Pin
George_George11-Sep-08 15:00
George_George11-Sep-08 15:00 
GeneralRe: what is method group? Pin
DaveyM6910-Sep-08 2:05
professionalDaveyM6910-Sep-08 2:05 

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.