Click here to Skip to main content
15,915,501 members
Home / Discussions / C#
   

C#

 
AnswerRe: get set property Pin
King Julien4-May-09 21:01
King Julien4-May-09 21:01 
GeneralRe: get set property Pin
OriginalGriff4-May-09 21:59
mveOriginalGriff4-May-09 21:59 
AnswerRe: get set property Pin
Member 44703545-May-09 0:00
Member 44703545-May-09 0:00 
QuestionHow to read CSV file Pin
kaushik_dass4-May-09 20:38
kaushik_dass4-May-09 20:38 
AnswerRe: How to read CSV file Pin
King Julien4-May-09 21:09
King Julien4-May-09 21:09 
GeneralRe: How to read CSV file Pin
kaushik_dass4-May-09 21:15
kaushik_dass4-May-09 21:15 
GeneralRe: How to read CSV file Pin
Dave Kreskowiak5-May-09 4:31
mveDave Kreskowiak5-May-09 4:31 
AnswerRe: How to read CSV file [modified] Pin
Jack Li4-May-09 21:46
Jack Li4-May-09 21:46 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;
using Excel = Microsoft.Office.Interop.Excel;
using System.Data.OleDb;
using System.Security.Cryptography;

public DataSet ExcelToDS(string Path)
{
//return one dataset

object missing = Missing.Value;
Excel.Application excelApp = new Excel.Application();
excelApp.Visible = false;
try
{
excelApp.Workbooks.Open(path, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
excelApp.Workbooks[1].Worksheets[i + 1];
Excel.Worksheet ws = (Excel.Worksheet)excelApp.Workbooks[1].Worksheets[1];
string sheetName = ws.Name;
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
DataSet ds = null;

strExcel = "select * from [" + sheetName + "$]";
myCommand = new OleDbDataAdapter(strExcel, strConn);
ds = new DataSet();
myCommand.Fill(ds);
conn.Close();
excelApp.Workbooks.Close();
excelApp.Quit();
excelApp = null;
return ds;
}
catch
{
MessageBox.Show("Not close EXCEL", "Err Info", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
KillProcess("EXCEL");
return null;
}
}

modified on Tuesday, May 5, 2009 3:52 AM

QuestionConfirm message on successful validation Pin
Ramkithepower4-May-09 20:27
Ramkithepower4-May-09 20:27 
AnswerRe: Confirm message on successful validation Pin
Christian Graus4-May-09 20:35
protectorChristian Graus4-May-09 20:35 
AnswerRe: Confirm message on successful validation [modified] Pin
mohmeh834-May-09 20:42
mohmeh834-May-09 20:42 
GeneralRe: Confirm message on successful validation Pin
Ramkithepower4-May-09 20:50
Ramkithepower4-May-09 20:50 
GeneralRe: Confirm message on successful validation [modified] Pin
mohmeh834-May-09 21:16
mohmeh834-May-09 21:16 
AnswerRe: Confirm message on successful validation Pin
Jack Li4-May-09 21:50
Jack Li4-May-09 21:50 
QuestionTyped DataSets Pin
Illegal Operation4-May-09 19:16
Illegal Operation4-May-09 19:16 
AnswerRe: Typed DataSets Pin
N a v a n e e t h4-May-09 19:36
N a v a n e e t h4-May-09 19:36 
AnswerRe: Typed DataSets Pin
saanj4-May-09 20:10
saanj4-May-09 20:10 
QuestionHow can I know raw header information through BHO? Pin
svt gdwl4-May-09 18:39
svt gdwl4-May-09 18:39 
Questiondebuggin in windows service Pin
mark_me4-May-09 13:54
mark_me4-May-09 13:54 
AnswerRe: debuggin in windows service Pin
N a v a n e e t h4-May-09 19:33
N a v a n e e t h4-May-09 19:33 
QuestionHighlight text in a datagridview cell. PinPopular
edlanka4-May-09 13:28
edlanka4-May-09 13:28 
QuestionDisplay image on Hover on a button in a winform Pin
edlanka4-May-09 11:43
edlanka4-May-09 11:43 
AnswerRe: Display image on Hover on a button in a winform Pin
Christian Graus4-May-09 12:05
protectorChristian Graus4-May-09 12:05 
GeneralRe: Display image on Hover on a button in a winform Pin
mohmeh834-May-09 19:51
mohmeh834-May-09 19:51 
QuestionProblem uninstalling win service Pin
mark_me4-May-09 9:52
mark_me4-May-09 9:52 

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.