Click here to Skip to main content
   

C#

 
AnswerRe: "sendkeys" does not work KnightOnline Pinmember ProgramFOX1-Jan-13 6:52 
AnswerIt's a game :) PinmemberEddy Vluggen1-Jan-13 7:01 
GeneralRe: It's a game :) Pinmember ProgramFOX1-Jan-13 7:05 
Generalto access latitudes and longitudes from database Pinmembernaveen 201230-Dec-12 23:28 
GeneralRe: to access latitudes and longitudes from database PinmvpOriginalGriff31-Dec-12 0:22 
GeneralRe: to access latitudes and longitudes from database PinprotectorPete O'Hanlon31-Dec-12 0:54 
GeneralRe: to access latitudes and longitudes from database PinmemberEnnis Ray Lynch, Jr.31-Dec-12 6:36 
GeneralRe: to access latitudes and longitudes from database PinmemberPIEBALDconsult31-Dec-12 7:22 
Questionhow to extract tag in regular expressions c# Pinmemberngoanrazor30-Dec-12 6:02 
AnswerRe: how to extract tag in regular expressions c# PinmemberPIEBALDconsult30-Dec-12 6:39 
GeneralRe: how to extract tag in regular expressions c# PinmvpOriginalGriff30-Dec-12 22:20 
GeneralRe: how to extract tag in regular expressions c# PinmemberZac Greve31-Dec-12 13:16 
GeneralRe: how to extract tag in regular expressions c# PinmemberPIEBALDconsult31-Dec-12 13:24 
QuestionBoolean function to return true/false PinmemberMember 970415330-Dec-12 3:57 
I have the following function which I got online, and have changed to suit my needs :-
 
        private Boolean SheetExists(string strFilename)
        {
            Boolean Match = false;
            OleDbConnection objConn = null;
            System.Data.DataTable dt = null;
            try
            {
                String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                    "Data Source=" + strFilename + ";Extended Properties=Excel 8.0;";
                objConn = new OleDbConnection(connString);
                objConn.Open();
                dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                String[] excelSheets = new String[dt.Rows.Count];
                int i = 0;
                foreach (DataRow row in dt.Rows)
                {
                    excelSheets[i] = row["TABLE_NAME"].ToString();
                    i++;
                }
                for (int j = 0; j < excelSheets.Length; j++)
                {
                    if (excelSheets[j] == "Sheet1$")
                    {
                        Match = true;
                    }
                }
                if (Match == true)
                    return true;
                else
                    return false;
            }
            finally
            {
                if (objConn != null)
                {
                    objConn.Close();
                    objConn.Dispose();
                }
                if (dt != null)
                {
                    dt.Dispose();
                }
            }
        }
 
Basically it checks if sheet1 exists in a workbook. I'm currently using the variable "Match" to obtain a "return true" or a "return false". I'm sure it possible to modify the code so that it returns the true/false directly, I just can't figure out how.
Any ideas? Thanks
AnswerRe: Boolean function to return true/false PinmvpRichard MacCutchan30-Dec-12 5:12 
GeneralRe: Boolean function to return true/false PinmemberMember 970415330-Dec-12 5:18 
GeneralRe: Boolean function to return true/false PinmvpRichard MacCutchan30-Dec-12 5:25 
GeneralRe: Boolean function to return true/false PinmemberMember 970415330-Dec-12 6:42 
GeneralRe: Boolean function to return true/false PinmvpRichard MacCutchan30-Dec-12 6:45 
AnswerRe: Boolean function to return true/false PinmemberMatt T Heffron3-Jan-13 20:54 
GeneralRe: Boolean function to return true/false PinmemberMember 97041533-Jan-13 22:00 
GeneralRe: Boolean function to return true/false PinmemberMember 97041537-Jan-13 10:55 
AnswerRe: Boolean function to return true/false PinmemberMatt T Heffron7-Jan-13 11:17 
GeneralRe: Boolean function to return true/false PinmemberMember 97041537-Jan-13 11:26 
AnswerRe: Boolean function to return true/false PinmemberMatt T Heffron7-Jan-13 12:01 
GeneralRe: Boolean function to return true/false PinmemberMember 97041537-Jan-13 12:30 
GeneralRe: Boolean function to return true/false PinmemberMember 97041537-Jan-13 12:57 
AnswerRe: Boolean function to return true/false PinmemberMatt T Heffron7-Jan-13 13:03 
GeneralRe: Boolean function to return true/false PinmemberMember 97041537-Jan-13 13:12 
AnswerRe: Boolean function to return true/false PinmemberMatt T Heffron7-Jan-13 13:29 
GeneralRe: Boolean function to return true/false PinmemberMember 97041537-Jan-13 13:39 
GeneralRe: Boolean function to return true/false PinmemberMatt T Heffron7-Jan-13 12:57 
GeneralRe: Boolean function to return true/false PinmemberMember 97041537-Jan-13 13:02 
QuestionC# data tranfer to form in textbox PinmemberMember 970663330-Dec-12 3:44 
AnswerRe: C# data tranfer to form in textbox PinmvpRichard MacCutchan30-Dec-12 5:29 
GeneralRe: C# data tranfer to form in textbox PinmemberMember 970663330-Dec-12 9:07 
GeneralRe: C# data tranfer to form in textbox PinmvpRichard MacCutchan30-Dec-12 23:10 
AnswerRe: C# data tranfer to form in textbox PinmemberBillWoodruff3-Jan-13 18:37 
QuestionHow to solve the following problem using StreamReader. Pinmemberdr_iton30-Dec-12 1:20 
AnswerRe: How to solve the following problem using StreamReader. Pinmemberjibesh30-Dec-12 2:19 
AnswerRe: How to solve the following problem using StreamReader. PinmvpRichard MacCutchan30-Dec-12 3:37 
GeneralRe: How to solve the following problem using StreamReader. Pinmemberdr_iton31-Dec-12 15:38 
GeneralRe: How to solve the following problem using StreamReader. PinmvpRichard MacCutchan31-Dec-12 23:36 
GeneralRe: How to solve the following problem using StreamReader. Pinmemberdr_iton1-Jan-13 9:58 
GeneralRe: How to solve the following problem using StreamReader. PinmvpRichard MacCutchan1-Jan-13 23:11 
GeneralRe: How to solve the following problem using StreamReader. Pinmemberdr_iton4-Jan-13 11:17 
GeneralRe: How to solve the following problem using StreamReader. PinmvpRichard MacCutchan5-Jan-13 2:18 
GeneralRe: How to solve the following problem using StreamReader. Pinmemberdr_iton5-Jan-13 3:58 
GeneralRe: How to solve the following problem using StreamReader. PinmvpRichard MacCutchan5-Jan-13 4:04 
QuestionData in GridView is not being displayed correctly PinmemberMember 970415329-Dec-12 12:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 30 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid