Click here to Skip to main content
15,905,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: an array question Pin
EliottA26-May-09 5:36
EliottA26-May-09 5:36 
GeneralRe: an array question Pin
bluetx26-May-09 5:39
bluetx26-May-09 5:39 
GeneralRe: an array question Pin
EliottA26-May-09 5:51
EliottA26-May-09 5:51 
GeneralRe: an array question Pin
fly90426-May-09 5:42
fly90426-May-09 5:42 
GeneralRe: an array question Pin
fly90426-May-09 5:39
fly90426-May-09 5:39 
GeneralRe: an array question Pin
bluetx26-May-09 5:43
bluetx26-May-09 5:43 
GeneralRe: an array question Pin
fly90426-May-09 5:45
fly90426-May-09 5:45 
GeneralRe: an array question Pin
tom57200726-May-09 5:45
tom57200726-May-09 5:45 
GeneralRe: an array question Pin
bluetx26-May-09 5:46
bluetx26-May-09 5:46 
GeneralRe: an array question Pin
EliottA26-May-09 5:50
EliottA26-May-09 5:50 
GeneralRe: an array question Pin
bluetx26-May-09 5:54
bluetx26-May-09 5:54 
GeneralRe: an array question Pin
fly90426-May-09 5:55
fly90426-May-09 5:55 
GeneralRe: an array question Pin
EliottA26-May-09 5:58
EliottA26-May-09 5:58 
GeneralRe: an array question Pin
fly90426-May-09 5:59
fly90426-May-09 5:59 
GeneralRe: an array question Pin
bluetx26-May-09 6:04
bluetx26-May-09 6:04 
GeneralRe: an array question Pin
fly90426-May-09 6:07
fly90426-May-09 6:07 
GeneralRe: an array question Pin
bluetx26-May-09 5:55
bluetx26-May-09 5:55 
GeneralRe: an array question Pin
fly90426-May-09 5:57
fly90426-May-09 5:57 
GeneralRe: an array question Pin
0x3c026-May-09 5:53
0x3c026-May-09 5:53 
Questionimporting data from a xls file to an array Pin
guchu26-May-09 4:29
guchu26-May-09 4:29 
AnswerRe: importing data from a xls file to an array Pin
EliottA26-May-09 4:39
EliottA26-May-09 4:39 
Questionreading an excel file Pin
guchu27-May-09 9:20
guchu27-May-09 9:20 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Excel = Microsoft.Office.Interop.Excel;

I am learning to use c# at the moment .. i have this code to read an excel file ... its incomplete now asi am yet to define the other varibles but as of now i want to have a user input in textbox1 and then that is to be the file name of the excel file to open ... can ne one help me

namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void label1_Click(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

private void label2_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
try
{
// open the users excel workbook.
Excel.Application ExcelApp = new Excel.ApplicationClass();
ExcelApp.Visible = true;
String WorkbookPath = "c:/Users/Guchu/Desktop/a.xls";
Excel.Workbook ExcelWorkbook = ExcelApp.Workbooks.Open(WorkbookPath, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true,false,0,true,false,false);
Excel.Sheets excelSheets = ExcelWorkbook.Worksheets;
string CurrentSheet = "CurrentSheet";
excelSheets = (Excel.Sheets) excelSheets.get_Item(CurrentSheet);

}
catch (Exception theException)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, theException.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, theException.Source);

MessageBox.Show(errorMessage, "Error");
}
}


private void button2_Click(object sender, EventArgs e)
{

}

}
}
AnswerRe: reading an excel file Pin
EliottA27-May-09 9:23
EliottA27-May-09 9:23 
GeneralRe: reading an excel file Pin
guchu27-May-09 9:29
guchu27-May-09 9:29 
GeneralRe: reading an excel file Pin
EliottA27-May-09 9:44
EliottA27-May-09 9:44 

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.