Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
Questionsystem tray Pin
shashank veerkar4-Oct-05 18:21
shashank veerkar4-Oct-05 18:21 
AnswerRe: system tray Pin
Member 23314964-Oct-05 22:12
Member 23314964-Oct-05 22:12 
AnswerRe: system tray Pin
enjoycrack5-Oct-05 14:41
enjoycrack5-Oct-05 14:41 
QuestionDraw Pin
Tran Ngoc Minh4-Oct-05 17:52
Tran Ngoc Minh4-Oct-05 17:52 
AnswerRe: Draw Pin
enjoycrack5-Oct-05 14:35
enjoycrack5-Oct-05 14:35 
QuestionUsing OLE Object Pin
Sarat Gollapudi4-Oct-05 17:44
Sarat Gollapudi4-Oct-05 17:44 
QuestionOpen Excel Project Pin
azusakt4-Oct-05 17:14
azusakt4-Oct-05 17:14 
AnswerRe: Open Excel Project Pin
sean_mufc5-Oct-05 7:22
sean_mufc5-Oct-05 7:22 
I had a big headache trying to do this myself. There may be a way to read and write to a file, but I found I a diffent way to write to Excel, and a different was of reading from, with some help from one of our friends on the CodeProject.
Here is a simple example of writing to Excel. It creates a new Excel book and writes a string in the 1st cell.

/**************************************************/
using System;
using Excel;
using System.IO;
using System.Text;
using System.Data.OleDb;

namespace Writing_to_Excel_example
{

class Class1
{
static void Main(string[] args)
{
bool xlsError = false;
int rowCount = 0;
int counter = 0;
int counter2 = 0;


Console.WriteLine("Working...");
Excel.Application ExcelObj = new Excel.Application();
Excel.Workbook workbook = ExcelObj.Workbooks.Add(Type.Missing);

if (ExcelObj == null)
{
Console.WriteLine("\nERROR: EXCEL couldn't be started!");
xlsError = true;
}

// activate the active worksheet in the workbook
Worksheet ws = (Worksheet)ExcelObj.ActiveSheet;
ws.Activate();
try
{
//To enter text to a specific row and column:
((Range)ws.Cells[1, 1]).Value2 = ("This is Row 1, Column 1");

//To set an entire row as Bold.
((Range)ws.Cells[rowCount, 1]).EntireRow.Font.Bold = true;

}//end try
catch(Exception e)
{
Console.Write(e);
}

//Make Excel visible.
ExcelObj.Visible = true;
}
}
}
/***************************************************************/
DONT FORGET TO ADD REFERENCE TO EXCEL 11.0 OBJECT LIBRARY!!

As for reading from excel, I tried to apply the same sort of logic as above but it didn't work. So have a look at this link:
http://www.codeproject.com/csharp/FasterExcelAccessTOC.asp[^]

Great tips there, a great help to me, Thanks to Dusty Candland, great help mate!!

t-seanm
QuestionFile Copy Agent Printer Pin
Member 24613494-Oct-05 16:33
Member 24613494-Oct-05 16:33 
AnswerRe: File Copy Agent Printer Pin
Matthew134569844-Oct-05 17:30
sussMatthew134569844-Oct-05 17:30 
QuestionButton with a drop-down arrow Pin
David Wengier4-Oct-05 14:30
David Wengier4-Oct-05 14:30 
AnswerRe: Button with a drop-down arrow Pin
ehuysamer4-Oct-05 22:46
ehuysamer4-Oct-05 22:46 
AnswerRe: Button with a drop-down arrow Pin
Andy Moore5-Oct-05 6:48
Andy Moore5-Oct-05 6:48 
QuestionGenerate subsets from a string Pin
JoaoPe4-Oct-05 12:44
JoaoPe4-Oct-05 12:44 
AnswerRe: Generate subsets from a string Pin
Robert Rohde4-Oct-05 19:37
Robert Rohde4-Oct-05 19:37 
Questionhow handle objects and code of setup forms? Pin
Sasuko4-Oct-05 12:43
Sasuko4-Oct-05 12:43 
Questionhow to display script message? Pin
kani984-Oct-05 11:26
kani984-Oct-05 11:26 
AnswerRe: how to display script message? Pin
enjoycrack5-Oct-05 14:43
enjoycrack5-Oct-05 14:43 
GeneralRe: how to display script message? Pin
kani986-Oct-05 7:49
kani986-Oct-05 7:49 
GeneralRe: how to display script message? Pin
enjoycrack6-Oct-05 10:48
enjoycrack6-Oct-05 10:48 
GeneralRe: how to display script message? Pin
kani986-Oct-05 10:56
kani986-Oct-05 10:56 
GeneralRe: how to display script message? Pin
enjoycrack6-Oct-05 15:03
enjoycrack6-Oct-05 15:03 
Questionloop Problem with method Pin
james3774-Oct-05 11:01
james3774-Oct-05 11:01 
AnswerRe: loop Problem with method Pin
Heath Stewart4-Oct-05 11:23
protectorHeath Stewart4-Oct-05 11:23 
Questionantivirus and antivirus API Pin
Mridang Agarwalla4-Oct-05 10:02
Mridang Agarwalla4-Oct-05 10:02 

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.