How to write Excel files in C#

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 29

  • @DarrenG
    @DarrenG  2 года назад +2

    Thanks for watching! If you have any questions just let me know!!

    • @dhairyakhanna277
      @dhairyakhanna277 Год назад

      just tell me where cellrange.set_Value method is coming ??

    • @johncenator3146
      @johncenator3146 4 месяца назад

      I'm late but if you want to write to the file rather than just create a new one couldn't you just programmatically set that file to have read - write permissions with a powershell script?

  • @troylambert3190
    @troylambert3190 Год назад

    I never thought Nick Kroll with a different haircut would ever help me with Excel interoperability but here we are! (Good video in all seriousness)

  • @mohammedghafri4258
    @mohammedghafri4258 2 года назад +3

    That was a great tutorial! but I have a little note; set_Value attribute does not exist in my visual studio 2022 and I think Value2 attribute is the alternative for that.
    Thank you man!

  • @GmanGavin1
    @GmanGavin1 2 года назад

    This is such a great tutorial.

  • @newmarek3
    @newmarek3 2 года назад +3

    To help someone of you save time. If you want it to create a file programmatically. Instead of wb=excel.Workbooks.open(); you want wb=excel.Workbooks.add(); and if you dont want it to ask you to save before you close you want excel.DisplayAlerts = False; then you need: object missingValue = System.Reflection.Missing.Value; because your close statement is wb.Close(false, missingValue, missingValue);

  • @vorapobautomation9760
    @vorapobautomation9760 2 месяца назад

    How to load Data From Notepad (.CSV) to DataGridView in C# Windows Form Application ?

  • @kanadalux3621
    @kanadalux3621 Год назад

    Amigo, una consulta por favor, quiero escribir formulas anidadas en una celda usando C# pero esas fórmulas se generan concatenando variable. El error que presenta es que se inserta la fórmula pero con un @ antes de "=". Ya probé usar diferentes librerias como EPPLUS, NPOI , y sigo con ese error .

  • @ThaoMeoTV
    @ThaoMeoTV 2 года назад

    Thanks sir!

  • @Dandanukadan
    @Dandanukadan 2 года назад +1

    Thanks Darren, a few quick feedback and requests as follows
    1]Your tutorials are awesome but if you can slow it down a little bit it helps newbies like me to understand fully what you are trying to explain.
    2)Would you helps us with the following request - I want to enter value dynamically in a text box during run time and that needs to be captured in a parameter to be parsed onto Excel.
    Thank you.

    • @DarrenG
      @DarrenG  Год назад +1

      I'm sorry that I go to fast, I think the real issue comes down to how I edited the video for RUclips. I cut out the silence and it just creates a very fast paced video.

  • @frevanneste7595
    @frevanneste7595 Год назад +1

    hi, If you make a template in excel and write into that template, will this work once you publish the app, if the user doesn't have the template locally on his computer (he only has the published app)?

    • @DarrenG
      @DarrenG  Год назад +1

      If I'm understanding you correctly, the user would definitely need the template.... You are effectively copying the template and editing it while you copy it.
      If the file isn't in place to be copied, that's an error.

  • @aritrapaul1418
    @aritrapaul1418 6 месяцев назад

    Thanks bro

  • @jeremiahsease5784
    @jeremiahsease5784 Год назад

    Okay So how you write to excel using blazor?

  • @ShashankNaik-ml2mh
    @ShashankNaik-ml2mh 7 месяцев назад +1

    WriteExcel function is not showing.its showing error

  • @OranMcGread
    @OranMcGread 2 года назад

    Thanks for the video, how would you add data to the next empty column in the spreadsheet instead of specifying the range?

    • @DarrenG
      @DarrenG  2 года назад +2

      To my knowledge, You do have to specify the range
      You can use worksheet.UsedRange() to get the currently used range, which would then allow you to figure out where the next unused cell is located to declare your range to add the data.
      Hopefully that makes sense
      docs.microsoft.com/en-us/dotnet/api/microsoft.office.tools.excel.worksheet.usedrange?view=vsto-2017

    • @OranMcGread
      @OranMcGread 2 года назад

      @@DarrenG thanks I’ll look into that

  • @humanaccount2754
    @humanaccount2754 Год назад

    thank you

  • @codymckinney4934
    @codymckinney4934 9 месяцев назад

    "cannot use object linking or embedding" error when opening the excel file and running code

  • @lemonlearner7315
    @lemonlearner7315 2 года назад +1

    hey!! nice video! how can i delete an entire row?

    • @lemonlearner7315
      @lemonlearner7315 2 года назад +1

      hey, you can delete an entire row with the next code:
      cell.EntireRow.Delete(Type.Missing); //cell contains the range

  • @fabianralph5472
    @fabianralph5472 2 года назад +2

    How to fix read only ?

    • @johncenator3146
      @johncenator3146 4 месяца назад

      Use a bash or powershell script or manually edit the permissions on the file.

  • @kxrxbo
    @kxrxbo 7 месяцев назад

    Where are you rushing to ?😂

  • @GreyHatGenX
    @GreyHatGenX Год назад

    commnet

  • @igorthelight
    @igorthelight 2 года назад +1

    A working and commented code (it's a Console application tho):
    using Microsoft.Office.Interop.Excel;
    using System;
    namespace ExcelParser
    {
    internal class Program
    {
    static void Main(string[] args)
    {
    WriteExcel(@"C:\sheet.xlsx");
    Console.ReadKey();
    }
    static void WriteExcel(string filePath)
    {
    Application excel = new Application();
    Workbook wb = excel.Workbooks.Open(filePath);
    Worksheet ws = wb.Worksheets[1];
    // Reading and wrtiting to one cell
    //Range cell = ws.Cells[1, 3]; // Less human friendly way
    Range cell = ws.Range["C1"];
    cell.Value = "Pizza";
    // Writing to a whole row or column
    Range cells = ws.Range["C1:F1"];
    string[] things = { "WOW!", "Hamburger", "Cars", "Trees" };
    cells.set_Value(XlRangeValueDataType.xlRangeValueDefault, things);
    wb.Save();
    //wb.SaveAs(filePath); // If you want to save it with another name or in another folder
    wb.Close();
    }
    }
    }