Click here to Skip to main content
15,924,193 members
Home / Discussions / C#
   

C#

 
GeneralRe: Updating Winforms and multi-threading Pin
led mike6-Mar-08 9:26
led mike6-Mar-08 9:26 
GeneralRe: Updating Winforms and multi-threading Pin
Luc Pattyn6-Mar-08 9:16
sitebuilderLuc Pattyn6-Mar-08 9:16 
GeneralRe: Updating Winforms and multi-threading Pin
Jergosh6-Mar-08 9:24
Jergosh6-Mar-08 9:24 
GeneralRe: Updating Winforms and multi-threading Pin
Luc Pattyn6-Mar-08 9:33
sitebuilderLuc Pattyn6-Mar-08 9:33 
Generalgzip library Pin
damianrda6-Mar-08 7:39
damianrda6-Mar-08 7:39 
GeneralRe: gzip library Pin
Not Active6-Mar-08 8:03
mentorNot Active6-Mar-08 8:03 
QuestionInterop Access Violation Pin
Member 45984256-Mar-08 7:27
Member 45984256-Mar-08 7:27 
QuestionHow do I determine the end-of-file in a spreadsheet/excel application Pin
Walaza6-Mar-08 6:15
Walaza6-Mar-08 6:15 
Hi,

I developed an application that opens an excel doc, and reads/displays its contents to a datagrid. How do I determine its start and end rows? I have tried some code but it does not give me the result I need. e.g. I tried:
//get start and end rows
Object[] startRow = {worksheet.get_Range("A4", "O4")};
Object[] endRow = {worksheet.Rows.get_End(XlDirection.xlDown)};

which did not work for me.

See below:

// loop through all rows of the spreadsheet and place each row in the datagrid.
for (int i = 4; i <= 50; i++)
{
Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("A" + i.ToString(), "Z" + i.ToString());
System.Array myvalues = (System.Array)range.Cells.Value2;

string[] strArray = ConvertToStringArray(myvalues);

DataGridViewRow row = new DataGridViewRow();
Object[] vals = strArray;
row.CreateCells(dgOutput, vals);
dgOutput.Rows.Add(row);
}

This displays the 1st 50 rows. I do not want to display 50 rows, I want to display all the rows in the spreadsheet. I need a variable that will replace the 50 (in the for loop) and represent the end-of-file.
Please help. D'Oh! | :doh:

Mvelo Walaza
Developer
Telkom SA

AnswerRe: How do I determine the end-of-file in a spreadsheet/excel application Pin
Jimmanuel6-Mar-08 7:30
Jimmanuel6-Mar-08 7:30 
GeneralRe: How do I determine the end-of-file in a spreadsheet/excel application Pin
Walaza6-Mar-08 19:47
Walaza6-Mar-08 19:47 
GeneralRe: How do I determine the end-of-file in a spreadsheet/excel application Pin
Jimmanuel7-Mar-08 2:52
Jimmanuel7-Mar-08 2:52 
GeneralAssociate File Extension with Internet Explorer Pin
Brad Wick6-Mar-08 6:12
Brad Wick6-Mar-08 6:12 
GeneralRe: Associate File Extension with Internet Explorer Pin
Not Active6-Mar-08 8:00
mentorNot Active6-Mar-08 8:00 
GeneralOpening a form inside other form Pin
NewToAspDotNet6-Mar-08 6:07
NewToAspDotNet6-Mar-08 6:07 
GeneralRe: Opening a form inside other form Pin
#realJSOP6-Mar-08 6:09
professional#realJSOP6-Mar-08 6:09 
GeneralRe: Opening a form inside other form Pin
NewToAspDotNet6-Mar-08 6:53
NewToAspDotNet6-Mar-08 6:53 
GeneralRe: Opening a form inside other form Pin
Dan Neely6-Mar-08 7:02
Dan Neely6-Mar-08 7:02 
GeneralRe: Opening a form inside other form Pin
Anthony Mushrow6-Mar-08 7:08
professionalAnthony Mushrow6-Mar-08 7:08 
GeneralRe: Opening a form inside other form Pin
Luc Pattyn6-Mar-08 7:30
sitebuilderLuc Pattyn6-Mar-08 7:30 
GeneralRe: Opening a form inside other form Pin
darkelv6-Mar-08 15:49
darkelv6-Mar-08 15:49 
GeneralWindows Service Question Pin
#realJSOP6-Mar-08 5:57
professional#realJSOP6-Mar-08 5:57 
GeneralRe: Windows Service Question Pin
Ernest Laurentin6-Mar-08 6:31
Ernest Laurentin6-Mar-08 6:31 
GeneralRe: Windows Service Question Pin
#realJSOP6-Mar-08 7:20
professional#realJSOP6-Mar-08 7:20 
GeneralRe: Windows Service Question Pin
Ernest Laurentin6-Mar-08 7:26
Ernest Laurentin6-Mar-08 7:26 
GeneralRe: Windows Service Question Pin
#realJSOP6-Mar-08 8:34
professional#realJSOP6-Mar-08 8:34 

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.