Click here to Skip to main content
15,896,308 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: reading an excel file Pin
guchu27-May-09 10:00
guchu27-May-09 10:00 
GeneralRe: reading an excel file Pin
EliottA27-May-09 10:03
EliottA27-May-09 10:03 
GeneralRe: reading an excel file Pin
guchu27-May-09 10:07
guchu27-May-09 10:07 
QuestionDownloading .MP3 file Pin
gmhanna26-May-09 4:27
gmhanna26-May-09 4:27 
AnswerRe: Downloading .MP3 file Pin
Luc Pattyn26-May-09 4:32
sitebuilderLuc Pattyn26-May-09 4:32 
Questionconnection string Pin
Ahmed Khallaf26-May-09 4:19
Ahmed Khallaf26-May-09 4:19 
AnswerRe: connection string Pin
EliottA26-May-09 4:25
EliottA26-May-09 4:25 
AnswerRe: connection string Pin
tom57200726-May-09 4:26
tom57200726-May-09 4:26 
AnswerRe: connection string Pin
sitowxh26-May-09 5:10
sitowxh26-May-09 5:10 
AnswerRe: connection string Pin
Dave Kreskowiak26-May-09 7:44
mveDave Kreskowiak26-May-09 7:44 
Question.config being overwritten Pin
Programm3r26-May-09 4:04
Programm3r26-May-09 4:04 
QuestionHow to access the base registery from a thread? Pin
Doria228626-May-09 3:58
Doria228626-May-09 3:58 
AnswerRe: How to access the base registery from a thread? Pin
Eddy Vluggen26-May-09 6:24
professionalEddy Vluggen26-May-09 6:24 
AnswerRe: How to access the base registery from a thread? Pin
Dave Kreskowiak26-May-09 7:42
mveDave Kreskowiak26-May-09 7:42 

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.