Click here to Skip to main content
15,921,716 members
Home / Discussions / C#
   

C#

 
AnswerRe: Write data to an xml file Pin
Nader Elshehabi8-Sep-06 11:14
Nader Elshehabi8-Sep-06 11:14 
AnswerRe: Write data to an xml file Pin
Guffa8-Sep-06 13:18
Guffa8-Sep-06 13:18 
GeneralRe: Write data to an xml file Pin
lmoelleb8-Sep-06 20:47
lmoelleb8-Sep-06 20:47 
AnswerRe: Write data to an xml file Pin
Guffa9-Sep-06 7:53
Guffa9-Sep-06 7:53 
AnswerRe: Write data to an xml file Pin
Arjun "Mjolnir" Bahree10-Sep-06 4:25
Arjun "Mjolnir" Bahree10-Sep-06 4:25 
QuestionBuffering Images Pin
Randomlick8-Sep-06 9:53
Randomlick8-Sep-06 9:53 
QuestionMax Number of Processes limit Pin
Subby Dev8-Sep-06 8:59
Subby Dev8-Sep-06 8:59 
Questionhow to create a System.data.datatabe from interop.excel.worksheet? Pin
qahwah8-Sep-06 7:54
qahwah8-Sep-06 7:54 
Is it possible to create a system.data.datatable or dataset from an excel worksheet that is obtained using interop.excel in C#?

The code is as following. As you can see, I can read/modify certain cell, but is it possible to convert the table to a System.data.datatable? Or at least print out the select range in the excelworksheet?

protected void OpenExcelSpreadSheet(string input)
{
Excel.Application excelApp = new Excel.ApplicationClass();
excelApp.Visible = false;
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);

// The following code opens an existing workbook
object Missing = System.Reflection.Missing.Value;
string workbookPath= "myFile.xls";
Excel.Workbook excelWorkbook =
excelApp.Workbooks.Open(workbookPath,Missing,Missing,Missing,
Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing);

// The following gets the Worksheets collection
Excel.Sheets excelSheets = excelWorkbook.Worksheets;

// The following gets Sheet1 for editing
string currentSheet = "Sheet1";
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);

// The following gets cell A1 for editing
Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "A1");
excelCell.Value2 = input;

Excel.Range excelTable = (Excel.Range)excelWorksheet.get_Range("A1", "A27");

int noOfRow = excelTable.Rows.Count;
int noOfColumn = excelTable.Columns.Count;
Response.Write("Table has " + noOfRow + " rows and " + noOfColumn + " columns.
");

}

QuestionDigit To text Converter [modified] Pin
Syed Shahid Hussain8-Sep-06 6:50
Syed Shahid Hussain8-Sep-06 6:50 
AnswerRe: Digit To text Converter Pin
leppie8-Sep-06 7:11
leppie8-Sep-06 7:11 
GeneralRe: Digit To text Converter Pin
Syed Shahid Hussain8-Sep-06 8:09
Syed Shahid Hussain8-Sep-06 8:09 
GeneralRe: Digit To text Converter Pin
Syed Shahid Hussain8-Sep-06 9:12
Syed Shahid Hussain8-Sep-06 9:12 
GeneralRe: Digit To text Converter Pin
Nader Elshehabi8-Sep-06 9:18
Nader Elshehabi8-Sep-06 9:18 
AnswerRe: Digit To text Converter Pin
Nader Elshehabi8-Sep-06 9:54
Nader Elshehabi8-Sep-06 9:54 
GeneralRe: Digit To text Converter Pin
Syed Shahid Hussain9-Sep-06 5:56
Syed Shahid Hussain9-Sep-06 5:56 
JokeRe: Digit To text Converter Pin
Nader Elshehabi9-Sep-06 6:59
Nader Elshehabi9-Sep-06 6:59 
GeneralRe: Digit To text Converter Pin
Syed Shahid Hussain10-Sep-06 8:50
Syed Shahid Hussain10-Sep-06 8:50 
AnswerRe: Digit To text Converter Pin
Arjun "Mjolnir" Bahree10-Sep-06 4:31
Arjun "Mjolnir" Bahree10-Sep-06 4:31 
GeneralRe: Digit To text Converter Pin
Syed Shahid Hussain10-Sep-06 8:54
Syed Shahid Hussain10-Sep-06 8:54 
QuestionHow to convert string Pin
papa808-Sep-06 6:25
papa808-Sep-06 6:25 
AnswerRe: How to convert string Pin
Not Active8-Sep-06 6:38
mentorNot Active8-Sep-06 6:38 
GeneralRe: How to convert string Pin
papa808-Sep-06 6:42
papa808-Sep-06 6:42 
GeneralRe: How to convert string Pin
KevinMac8-Sep-06 6:54
KevinMac8-Sep-06 6:54 
GeneralRe: How to convert string Pin
papa808-Sep-06 7:34
papa808-Sep-06 7:34 
QuestionDuplicate GUIDs? Pin
Xiangyang Liu 刘向阳8-Sep-06 6:15
Xiangyang Liu 刘向阳8-Sep-06 6:15 

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.