Click here to Skip to main content
16,023,103 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an excel file which is used to batch process an XML file. the process makes a copy of the XML file.

In the excel file. There's a list of file names.

if the file name matches the previous row then it'll append the copy in the same file or if not then will create a new file with the file name.

I am thinking of getting the values of each row and process it. (I am not even if its the right way of doing it)
However, I am sure how to go about doing that. I was able to get column names of the first column via column names function.

What I have tried:

var excelFile = new ExcelQueryFactory(excelPath);
IQueryable<Row> excelSheetValues = from workingSheet in excelFile.Worksheet(sheetName) select workingSheet;
string[] headerRow = excelFile.GetColumnNames(sheetName).ToArray(); 
Posted
Updated 8-Jan-17 5:23am
v2
Comments
OriginalGriff 7-Jan-17 5:06am    
And?
What is the problem?
What have you tried?
Where are you stuck?
What help do you need?
Use the "Improve question" widget to edit your question and provide better information.
#realJSOP 8-Jan-17 6:30am    
It might help if you metion the fact that you're using the ExcelQueryFactory library, and then what you've actually tried soe that someone can give an answer that gets you where you want to go.

I am not exactly clear on what you are trying to accomplish. But you certainly use C# to fetch row data using a code similar to the following:

private void LoadData()
        {
            OleDbConnection con = new OleDbConnection();
            try
            {
                String strConnectionString = @"Provider = Microsoft.Jet.OLEDB.4.0; Mode = 16; Data Source = " + System.Configuration.ConfigurationSettings.AppSettings["DatabaseLocation"] + "; Extended Properties = " + "\"Excel 8.0;\"";
                con.ConnectionString = strConnectionString;
                OleDbCommand cmdFetchExistingRecord = new OleDbCommand();
                cmdFetchExistingRecord.Connection = con;
                DataSet dataSet = new DataSet();
                cmdFetchExistingRecord.CommandText = "SELECT * FROM MyTable";
                OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(cmdFetchExistingRecord);
                con.Open();
                oleDbDataAdapter.Fill(dataSet, "hData");

                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    txtAgency_State.Text = DecryptData(dataSet.Tables[0].Rows[0]["Agency_State"].ToString());
                }
                else
                {
                }
            }
            catch
            {
                MessageBox.Show("An unexpected error occurred.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                con.Close();
            }
        }
 
Share this answer
 
I'd suggest to read this: C#: Query Excel and .CSV Files Using LinqToExcel[^]

Your question is not clear, so i cannot provide more details about LinqToExcel.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900