How to read Excel files in C#

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ก.พ. 2025

ความคิดเห็น • 32

  • @christiangibbs8534
    @christiangibbs8534 2 ปีที่แล้ว +4

    Thanks very much. The other tutorials and articles made this SO much more complicated than it needed to be!

  • @raduparfenie8383
    @raduparfenie8383 11 หลายเดือนก่อน +1

    Well done! Clear and concise.

  • @nakorns320
    @nakorns320 2 ปีที่แล้ว +2

    Simply and good teaching, thank you, sir.

  • @gruzifigs
    @gruzifigs ปีที่แล้ว

    finally someone who writes logical codes

  • @BaldurTheWhite
    @BaldurTheWhite ปีที่แล้ว

    This worked for me. Thank you so much. It was plain and simple.

  • @melanieschneider8158
    @melanieschneider8158 2 ปีที่แล้ว +1

    Thanks, that saved me so much reading

  • @1pomii
    @1pomii 3 ปีที่แล้ว +1

    needed this for my job, thank you!

    • @DarrenG
      @DarrenG  3 ปีที่แล้ว +1

      I was doing it for mine and figured I would make a one off app showing how to do it lol

  • @МихаилКлинцов-б9у
    @МихаилКлинцов-б9у ปีที่แล้ว +3

    Я конечно не понимаю английский, но этот человек объяснил работу с excel гораздо понятнее чем другие блогеры на русском.

  • @xsandwichxxsandwichx1778
    @xsandwichxxsandwichx1778 2 ปีที่แล้ว +1

    I like your style

  • @letenyeidam89
    @letenyeidam89 2 ปีที่แล้ว +1

    Thank you!

  • @valoire
    @valoire 2 ปีที่แล้ว +2

    using Excel = Microsoft.Office.Interop.Excel will allow you to shortcut the explicit declaration every time; just a tip :)

    • @DarrenG
      @DarrenG  2 ปีที่แล้ว +4

      Hey that's awesome! Thanks!

  • @DenisOrlandiDeSouza
    @DenisOrlandiDeSouza 3 หลายเดือนก่อน

    How to read from the binary instead of FilePath?

  • @BCTAHbKA
    @BCTAHbKA 2 ปีที่แล้ว

    Bu, ən yaxşı videodur

  • @dbest19330
    @dbest19330 2 ปีที่แล้ว

    Well done :)

  • @claymore2000
    @claymore2000 2 ปีที่แล้ว

    How do export this to the end user? I’m working ok similar stuff for my economy guys and they aren’t tech savvy at all.
    Is it easiest to export this code as an .exe?

  • @ghostprogramming
    @ghostprogramming 9 หลายเดือนก่อน

    What to do with that?
    Cannot convert source type 'object' to target type 'Microsoft.Office.Interop.Excel.Worksheet'

  • @coding_ideas
    @coding_ideas 2 ปีที่แล้ว +1

    thanks

  • @igorthelight
    @igorthelight 2 ปีที่แล้ว

    Working and commented code (it's a Console application tho):
    using System;
    using Microsoft.Office.Interop.Excel;
    namespace ExcelParser
    {
    internal class Program
    {
    static void Main(string[] args)
    {
    ReadExcel(@"C:\sheet.xlsx");
    Console.ReadKey();
    }
    static void ReadExcel(string filename)
    {
    Application excel = new Application();
    Workbook wb = excel.Workbooks.Open(filename);
    Worksheet ws = wb.Worksheets[1];
    // Reading one cell
    //Range cell = ws.Cells[1, 1]; // Less human friendly way
    Range cell = ws.Range["A1"];
    Console.WriteLine(cell.Value);
    // Reading the whole row or column
    Range cells = ws.Range["A1:A3"];
    foreach (string item in cells.Value)
    {
    Console.WriteLine(item);
    }
    wb.Close();
    }
    }
    }

  • @mfsalatino
    @mfsalatino 2 ปีที่แล้ว

    when i try to read it appearme this error System.MissingMemberException: 'Public member 'Value' on type 'Range' not found.'.
    what can i do ?

  • @robertsimpson7857
    @robertsimpson7857 ปีที่แล้ว

    What if you reading a cell with a date? what changes will you make to the code? A new learner

  • @MatyasInzsol
    @MatyasInzsol 2 ปีที่แล้ว

    The "Workbook" word underline the c# in my project

  • @rashmiverma2326
    @rashmiverma2326 2 ปีที่แล้ว

    Hi, can you tell how to read password protected Excel file?

  • @jonatasviana4041
    @jonatasviana4041 2 ปีที่แล้ว +1

    Salve me, obrigado

  • @fabianralph5472
    @fabianralph5472 2 ปีที่แล้ว

    'Cannot convert type 'char' to 'string'' how to fix?

    • @fabianralph5472
      @fabianralph5472 2 ปีที่แล้ว

      I literally copy all your methods

  • @JoWood2000
    @JoWood2000 2 ปีที่แล้ว

    Why I am getting a "System.__ComObject" instead of text from cell?

    • @DarrenG
      @DarrenG  2 ปีที่แล้ว

      Maybe you are reading the cell instead of the cell's value. That's my guess.

    • @JoWood2000
      @JoWood2000 2 ปีที่แล้ว

      @@DarrenG Thank you for your answer but I fixed that problem. Greetings from Poland :)