Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3344402
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:03:55+00:00 2026-05-18T01:03:55+00:00

My question is very simillar to the one asked here: Reading Excel files from

  • 0

My question is very simillar to the one asked here: Reading Excel files from C#

My question is whether there is a new better way of doing this now (2 years later), if not does anybody have some examples of using the ACE OLEDB 12.0 witch seem to be the best way to go with it?

What I need to do is an application that reads an xlsx file every night, wrap the data in the excel sheet, and then save it to the database, any other tips?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:03:55+00:00Added an answer on May 18, 2026 at 1:03 am

    Using ExcelPackage you can iterate all sheets and columns like this:

    public class ExcelRead
    {
        public void ReadExcel()
        {
            FileInfo existingFile = new FileInfo(@"C:\temp\book1.xlsx");
            using (ExcelPackage xlPackage = new ExcelPackage(existingFile))
            {
                foreach (ExcelWorksheet worksheet in xlPackage.Workbook.Worksheets)
                {
                    var dimension = worksheet.Dimension();
                    for (int row = dimension.StartRow; row <= dimension.EndRow; row++)
                    {
                        for (int col = dimension.StartColumn; col <= dimension.EndColumn; col++)
                        {
                            Console.WriteLine(row + ":" + col + " - " + worksheet.Cell(row, col));
                        }
                    }
                }
            }
        }
    }
    
    public class Dimension
    {
        public int StartRow { get; set; }
        public int StartColumn { get; set; }
        public int EndRow { get; set; }
        public int EndColumn { get; set; }
    }
    
    public static class ExcelHelper
    {
        private static readonly char[] _numbers = new[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    
        public static Dimension Dimension(this ExcelWorksheet worksheet)
        {
            string range =
                worksheet.WorksheetXml.SelectSingleNode("//*[local-name()='dimension']").Attributes["ref"].Value;
            string[] rangeCoordinates = range.Split(':');
    
            int idx = rangeCoordinates[0].IndexOfAny(_numbers);
            int startRow = int.Parse(rangeCoordinates[0].Substring(idx));
            int startCol = ConvertFromExcelColumnName(rangeCoordinates[0].Substring(0, idx));
    
            if (rangeCoordinates.Length == 1)
                return new Dimension
                           {StartRow = startRow, StartColumn = startCol, EndRow = startRow, EndColumn = startCol};
    
            idx = rangeCoordinates[1].IndexOfAny(_numbers);
            int endRow = int.Parse(rangeCoordinates[1].Substring(idx));
            int endCol = ConvertFromExcelColumnName(rangeCoordinates[1].Substring(0, idx));
            return new Dimension {StartRow = startRow, StartColumn = startCol, EndRow = endRow, EndColumn = endCol};
        }
    
        public static int ConvertFromExcelColumnName(string name)
        {
            name = name.ToUpper();
            int result = 0;
            for (int i = 0; i < name.Length - 1; i++)
            {
                int val = name[i] - 64;
                int columnVal = (int) Math.Pow(26, name.Length - i - 1);
                result += val*columnVal;
            }
            result += name[name.Length - 1] - 64;
            return result;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.