Working with XLSX in JavaScript

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024

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

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

    I am only amazed at the kind of content and examples you give. This is super helpful and continue to deliver more great content Vincent :)

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

    Thank you soooo much. You've showed me more in 5 minutes than hours of documentation. Thank you for your work.

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

    I'm new to this. Do I need to download / install / src something in order to use fs, xlsx and jsontoxml?

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

    Thank you for the tutorial. Finally I realized that you actually meant "New Column" by "New Row".

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      Thank you for pointing it out. I always confuse rows and columns. I've changed the project files, but I can't really do anything about the video.

    • @Chandan7404
      @Chandan7404 3 ปีที่แล้ว

      @@VincentLabStudio In my country(🇧🇩) we have RC Cola (alongside Coca Cola and Pepsi Cola) which helps us remember that "R" comes as the first subscription number and then "C". 😄 ... thank you again all your videos. Hope to see more in coming days.
      en.wikipedia.org/wiki/RC_Cola

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      ​@@Chandan7404 Fun fact thanks 😄

  • @sephiroLord
    @sephiroLord 5 หลายเดือนก่อน

    This might be a dumb question, but is it possible for excel doc to be an api source? And if so. Can you point me to a resource

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

    Man I need your help !! … I’ll forever grateful. there’s a empty excel sheet, in that certain column have full of drop-down cell. It’s empty now. Now I have a JSON data to fill the excel sheet . Now how do I fill the excel sheet with json data. Like how do I fill the drop-down cell with dynamic data from the json ?? . The json data looks like this - array of objects, and each objects has one key called dropdown. That dropdown value is array of string. Please help me .what to do ??

  • @Шалобан
    @Шалобан ปีที่แล้ว

    This video is very helpful for me. Thanks.

  • @エド-i5f
    @エド-i5f 2 ปีที่แล้ว

    This can help me in the future project. thank you very much!

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

    Great explanation on this library!

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

    How to add heading in this excel which function to use

  • @エド-i5f
    @エド-i5f 2 ปีที่แล้ว

    I guess I can change the data by change Json witch is already in excel file?

  • @Kevin-pn9ri
    @Kevin-pn9ri ปีที่แล้ว

    Is there any way to keep the file open while it is being modified?

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

    Simple, informative and helpful 💪👍 Thanks a lot for this tutorial!

  • @tonypascoal998
    @tonypascoal998 4 ปีที่แล้ว

    Hy mr Vincent i love you're tutorials.. can you make a video explaining how to display pdf on mobiles with php or js.. without downloading. . Thank you a lot

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

    Thank you very much!

  • @VietLedeptrai
    @VietLedeptrai 3 ปีที่แล้ว

    Hello, thank you for your video. I have a question:
    - If I have an "id". I wanna del all the row that has the Id. How can I do it?

    • @VietLedeptrai
      @VietLedeptrai 3 ปีที่แล้ว

      For example, I want to delete a row with Id value = 2587. Thanks

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

      @@VietLedeptrai Try the code below.
      // Import dependencies
      const fs = require("fs");
      const XLSX = require("xlsx");
      const jsontoxml = require("jsontoxml");
      // Read the file into memory
      // const workbook = XLSX.read(fs.readFileSync("file-example.xlsx"));
      const workbook = XLSX.readFile("file-example.xlsx");
      // Convert the XLSX to JSON
      let worksheets = {};
      for (const sheetName of workbook.SheetNames) {
      worksheets[sheetName] = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]);
      }
      // Modify the XLSX
      worksheets.Sheet1 = worksheets.Sheet1.filter(function(item) {
      return item.Id !== 2587;
      });
      // Create a new XLSX file
      const newBook = XLSX.utils.book_new();
      const newSheet = XLSX.utils.json_to_sheet(worksheets.Sheet1);
      XLSX.utils.book_append_sheet(newBook, newSheet, "Sheet1");
      XLSX.writeFile(newBook,"new-book.xlsx");

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

    Hi, Can we use this to convert xls format file to xlsx?

  •  2 ปีที่แล้ว

    Excellent video. But how I delete a columns?

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

      Try the code below.
      // Import dependencies
      const fs = require("fs");
      const XLSX = require("xlsx");
      const jsontoxml = require("jsontoxml");
      // Read the file into memory
      // const workbook = XLSX.read(fs.readFileSync("file-example.xlsx"));
      const workbook = XLSX.readFile("file-example.xlsx");
      // Convert the XLSX to JSON
      let worksheets = {};
      for (const sheetName of workbook.SheetNames) {
      worksheets[sheetName] = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]);
      }
      // Modify the XLSX
      worksheets.Sheet1 = worksheets.Sheet1.filter(function(item) {
      return item.Id !== 2587;
      });
      // Create a new XLSX file
      const newBook = XLSX.utils.book_new();
      const newSheet = XLSX.utils.json_to_sheet(worksheets.Sheet1);
      XLSX.utils.book_append_sheet(newBook, newSheet, "Sheet1");
      XLSX.writeFile(newBook,"new-book.xlsx");

  • @hammadmusakhel5102
    @hammadmusakhel5102 3 ปีที่แล้ว

    why is the date in that format? can we change that?
    I wanted to make charts and as such with dates being the independent variable and the stock prices as the dependent variables. Pls help

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      That's a good question. I assume you can. But I'm not sure.
      Here is what I found on stack overflow:
      stackoverflow.com/questions/53163552/format-date-with-sheetjs

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

    how to import the dependencies? someone please answer, thankss

  • @sharadruthib6134
    @sharadruthib6134 3 ปีที่แล้ว

    can we make styling in this sheet. Something like a heading for the whole sheet

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      I don't know if it's possible, but I found a few different methods which might work. I have not tested them but I will give you the links here:
      www.npmjs.com/package/sheetjs-style
      www.npmjs.com/package/sheetjs-style-v2
      github.com/ShanaMaid/sheetjs
      There's also a pro version of this Library which I think can do it:
      sheetjs.com/pro
      I just found this on their documentation:
      "This is the community version. We also offer a pro version with performance enhancements, additional features like styling, and dedicated support"
      But I think the libraries I have linked above are a free version of their styling feature.

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

    can provide validations for an specific xl file before going to upload in react js

  • @achrafbouchiba3957
    @achrafbouchiba3957 4 ปีที่แล้ว

    Hello,
    How to add style to header xlsx ? thanks ;)

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

    hey how to make individual json files for each sheet in a xlsx file

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

      Try something like this:
      // Import dependencies
      const fs = require("fs");
      const XLSX = require("xlsx");
      // Read the file into memory
      const workbook = XLSX.readFile("file-example.xlsx");
      // Convert the XLSX to JSON
      for (const sheetName of workbook.SheetNames) {
      fs.writeFileSync(`${sheetName}.json`, JSON.stringify(XLSX.utils.sheet_to_json(workbook.Sheets[sheetName])));
      }

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

      @@VincentLabStudio this one worked like a charm, can we filter the empty cells too in this package? i didn't find anything in package docs

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

    How to get the sheetname?

  • @sudhansusekharpanda6510
    @sudhansusekharpanda6510 3 ปีที่แล้ว

    It was a really nice one. But I need to only write to the xls file? can you please share the code for only writing to the excel sheet? I tried with your code but it didnt work for me.

    • @sudhansusekharpanda6510
      @sudhansusekharpanda6510 3 ปีที่แล้ว

      Actually I have a requirement to only update the existing sheet i.e i need a method which ll simply write to the excel file.. to writing the excel file i need to pass some parameters like sheetname, column names to be filled up. can you please help me in this regard?

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

      @@sudhansusekharpanda6510 exact same task is given to me rn. Would be grateful if you could share how you did it.

  • @VishalKumar-yg8nh
    @VishalKumar-yg8nh 3 ปีที่แล้ว

    Thanks, this help me

  • @hammadmusakhel5102
    @hammadmusakhel5102 3 ปีที่แล้ว

    I also wanted to ask that why are you working on a js file? why not show it by working on a VueJs component?

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

      Because I like keeping back-end stuff in the back-end, and front-end stuff in the front-end.

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

    how to create dropdown ?

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

    Thank you.

  • @abdelrhmanshokr7546
    @abdelrhmanshokr7546 3 ปีที่แล้ว

    That was a pretty good tutorial I followed you step by step and it worked but now if I need to create a chart and push it to a work sheet is this possible ? whether it's using this package or any other one ? can anyone please help me ?

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

      Maybe this is helpful.
      Chartsheet Object
      Chartsheets are represented as standard sheets. They are distinguished with the !type property set to "chart".
      The underlying data and !ref refer to the cached data in the chartsheet. The first row of the chartsheet is the underlying header.
      Source: www.npmjs.com/package/xlsx or docs.sheetjs.com/
      I haven't tested it, but this might be what you're looking for.
      www.npmjs.com/package/xlsx-chart

    • @abdelrhmanshokr7546
      @abdelrhmanshokr7546 3 ปีที่แล้ว

      @@VincentLabStudio OK I'll give it a shot amd respond if it worked as I need, anyways thanks a lot for responding

    • @abdelrhmanshokr7546
      @abdelrhmanshokr7546 3 ปีที่แล้ว

      @@VincentLabStudio yes it worked thanks a lot for your help I really appreciate it it has a slight issue that it only creates one chart if you tried to create another one it overwrites what's in the file and creates the single latest chart I'm still trying to make it work.

  • @OdiaMadBiker
    @OdiaMadBiker 3 ปีที่แล้ว

    How to add cell styles in xlsx??

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      I don't know if it's possible, but I found a few different methods which might work. I have not tested them but I will give you the links here:
      www.npmjs.com/package/sheetjs-style
      www.npmjs.com/package/sheetjs-style-v2
      github.com/ShanaMaid/sheetjs
      There's also a pro version of this Library which I think can do it:
      sheetjs.com/pro
      I just found this on their documentation:
      "This is the community version. We also offer a pro version with performance enhancements, additional features like styling, and dedicated support"
      But I think the libraries I have linked above are a free version of their styling feature.

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

    How to deal with dates value please comment

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

      Here is what I found on stack overflow:
      stackoverflow.com/questions/53163552/format-date-with-sheetjs

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

      @@VincentLabStudio raw false give value in ddmmyy but required ddmmyyyy

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

    Hello, the video is very helpful, but now I'm currently working on a web app and I want the user to be able to print the file but I don't know how to do this with xlsx. If someone has an idea about it, I would be grateful to hear it :)

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

      th-cam.com/channels/bmwl3iMyHmjgcQzbgmgFGA.html

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

    How to delete worksheet?

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

      // Import dependencies
      const XLSX = require("xlsx");
      // Read the file into memory
      const workbook = XLSX.readFile("file-example.xlsx");
      // Create a new XLSX file
      const newBook = XLSX.utils.book_new();
      for (const sheetName of workbook.SheetNames) {
      // And here you add everything except the one you wanted to delete
      const newSheet = XLSX.utils.json_to_sheet(XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]));
      XLSX.utils.book_append_sheet(newBook, newSheet, sheetName);
      }
      XLSX.writeFile(newBook, "new-book.xlsx");

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

      @@VincentLabStudio thanks for this...but don't we have any function to delete it directly

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

      ​@@rajat420420 Unfortunately not

  • @MiguelAngel-yy5hp
    @MiguelAngel-yy5hp 3 ปีที่แล้ว

    how do I do this on the client-side ?

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

      I don't know if that would be possible. My recommendation would be to keep back-end functionality on the back end and then exchange information between the back-end and front-end, using an API.
      And if you want to upload a file from the front-end to the back-end, then you can follow the video linked down below. And the only part you would need to change is the way it handles the file once it's uploaded to the back-end.
      th-cam.com/video/KP_8gN8kh4Y/w-d-xo.html

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

    do you know how to style it ?

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

      I don't know if it's possible, but I found a few different methods which might work. I have not tested them but I will give you the links here:
      www.npmjs.com/package/sheetjs-style
      www.npmjs.com/package/sheetjs-style-v2
      github.com/ShanaMaid/sheetjs
      There's also a pro version of this Library which I think can do it:
      sheetjs.com/pro
      I just found this on their documentation:
      "This is the community version. We also offer a pro version with performance enhancements, additional features like styling, and dedicated support"
      But I think the libraries I have linked above are a free version of their styling feature.

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

      @@VincentLabStudio thank for your help

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

    Clear

  • @julistafita8022
    @julistafita8022 3 ปีที่แล้ว

    Thanks

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

    Be blessed by Lord Jesus Christ!