Click here to Skip to main content
15,922,696 members
Home / Discussions / C#
   

C#

 
GeneralRe: Multithreading Pin
Arun Bhalla22-Jul-03 12:40
Arun Bhalla22-Jul-03 12:40 
GeneralRe: Multithreading Pin
Alberto Bencivenni22-Jul-03 21:39
Alberto Bencivenni22-Jul-03 21:39 
GeneralRe: Multithreading Pin
Joe Woodbury23-Jul-03 6:27
professionalJoe Woodbury23-Jul-03 6:27 
QuestionHow to read data in excel file Pin
Hoang Dung21-Jul-03 18:38
Hoang Dung21-Jul-03 18:38 
AnswerRe: How to read data in excel file Pin
Mazdak21-Jul-03 20:01
Mazdak21-Jul-03 20:01 
AnswerRe: How to read data in excel file Pin
Kannan Kalyanaraman21-Jul-03 20:14
Kannan Kalyanaraman21-Jul-03 20:14 
GeneralRe: How to read data in excel file Pin
Ista24-Jul-03 5:57
Ista24-Jul-03 5:57 
AnswerRe: How to read data in excel file Pin
Ista24-Jul-03 6:48
Ista24-Jul-03 6:48 
This reads it into a DataTable

public void CreateXLSDataTable( String fileName )
{
//DataTable tb = new DataTable("XLS");
dtXLS = new DataTable();

Excel.Application ExcelObj = null;

ExcelObj = new Excel.Application();

if ( ExcelObj != null )
{
Excel.Workbook empBook = ExcelObj.Workbooks.Open(fileName,0,true,5,"","",true,
Excel.XlPlatform.xlWindows,"\t",false,false,0,true);
Excel.Sheets empSheets = empBook.Worksheets;

Excel.Worksheet empSheet = (Excel.Worksheet)empSheets.get_Item(1);

bool lineValid = true;
int iCount = 1;
while ( lineValid )
{
iCount++;
Excel.Range range = empSheet.get_Range("A"+iCount.ToString(), "X"+iCount.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
string[] strArray = ConvertToStringArray(myvalues);

if(strArray[0].Equals("") )
{
lineValid = false;
continue;
}


if( iCount != 2 )
{
object[] objArray = strArray;
dtXLS.Rows.Add(objArray);

}
else
{
for(int i=0; i< strArray.Length; i++)
{
dtXLS.Columns.Add(strArray[i]);
}
}



}


}
else
{
Trace.WriteLine("Excel reading Error: could not load the excel file object");
}

ExcelObj.Quit();
ExcelObj = null;
}

private 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().Trim();


}

return theArray;
}

public DataTable XLS
{
get
{
return dtXLS;
}
}
QuestionHow do i find a type of the object Pin
Ista21-Jul-03 17:03
Ista21-Jul-03 17:03 
AnswerRe: How do i find a type of the object Pin
Rocky Moore21-Jul-03 17:12
Rocky Moore21-Jul-03 17:12 
AnswerRe: How do i find a type of the object Pin
Meysam Mahfouzi22-Jul-03 0:41
Meysam Mahfouzi22-Jul-03 0:41 
AnswerRe: How do i find a type of the object Pin
LongRange.Shooter22-Jul-03 5:02
LongRange.Shooter22-Jul-03 5:02 
GeneralRe: How do i find a type of the object Pin
Ista22-Jul-03 8:16
Ista22-Jul-03 8:16 
GeneralRe: How do i find a type of the object Pin
LongRange.Shooter23-Jul-03 5:07
LongRange.Shooter23-Jul-03 5:07 
GeneralRe: How do i find a type of the object Pin
Ista24-Jul-03 6:05
Ista24-Jul-03 6:05 
GeneralBinding a domainUpDown control Pin
Ista21-Jul-03 17:02
Ista21-Jul-03 17:02 
GeneralADO.NET Connections and Connection Pools Pin
albean21-Jul-03 16:25
albean21-Jul-03 16:25 
GeneralRe: ADO.NET Connections and Connection Pools Pin
Rocky Moore21-Jul-03 17:20
Rocky Moore21-Jul-03 17:20 
GeneralSending an email. Pin
Alex Korchemniy21-Jul-03 15:38
Alex Korchemniy21-Jul-03 15:38 
GeneralRe: Sending an email. Pin
Rocky Moore21-Jul-03 15:46
Rocky Moore21-Jul-03 15:46 
GeneralRe: Sending an email. Pin
Alex Korchemniy21-Jul-03 16:15
Alex Korchemniy21-Jul-03 16:15 
GeneralRe: Sending an email. Pin
Rocky Moore21-Jul-03 17:14
Rocky Moore21-Jul-03 17:14 
GeneralRe: Sending an email. Pin
Heath Stewart21-Jul-03 18:14
protectorHeath Stewart21-Jul-03 18:14 
GeneralRe: Sending an email. Pin
Rocky Moore21-Jul-03 22:35
Rocky Moore21-Jul-03 22:35 
QuestionComparing Two Images in C# - Possible? Pin
CyberKewl21-Jul-03 15:24
CyberKewl21-Jul-03 15:24 

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.