Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Working with excel spreadsheets?

Discussion in 'Scripting' started by Alpha_Player, Jun 27, 2023.

  1. Alpha_Player

    Alpha_Player

    Joined:
    Jun 9, 2018
    Posts:
    3
    Hi. I have this Spreadsheet in my project. I need to access the file to read and write to this spreadsheet (the data is of course the most important part), plus reading and writing the formatting options for cells (mainly colour, border and text style) and adding / removing rows. I tried googling a bit but couldn't find much, all C# libraries for excel files seem to either be discontinued or incomplete; is there anything like openpyxl that works with C#?

    Also is there a way to work directly with Unity and the Google Sheets API? I need to upload any changes I make to the spreadsheets, but I checked the Google API and it doesn't seem to support C# so I don't think there's any direct way of interacting unity -> google sheets. It's not a problem right now as I have a python script that can upload/download the file, but maybe there's an easier solution and I missed something.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Yes. It's just a web call with some kind of auth token.

    It's a web API call, it has nothing to do with any programming language and also has nothing to do with Unity.

    Networking, UnityWebRequest, WWW, Postman, curl, WebAPI, etc:

    https://forum.unity.com/threads/using-unity-for-subscription-lists.1070663/#post-6910289

    https://forum.unity.com/threads/unity-web-request-acting-stupid.1096396/#post-7060150

    And setting up a proxy can be very helpful too, in order to compare traffic:

    https://support.unity.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity
     
  3. Alpha_Player

    Alpha_Player

    Joined:
    Jun 9, 2018
    Posts:
    3
    Hey, thanks for the reply.
    I'm not very experienced in these things, I was reading the tutorial on the Google Developers website:
    https://developers.google.com/sheets/api/guides/concepts
    Here, when I look at the quickstart guide it talks about a few different languages and installing the Google Sheets library.

    Also, do you know anything about my other question? That's my main concern.

    Thanks again for the reply
     
  4. Alpha_Player

    Alpha_Player

    Joined:
    Jun 9, 2018
    Posts:
    3
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Do you mean about the formatting and coloring? I know that's not portable. It might be exposed in the API somehow. Probably best to start with the docs. I have only used google sheets for localized text.

    Ideally keep all your data IN Unity, perhaps in a CSV file you parse, or else in ScriptableObjects or JSON.

    Adding an extra external step is only justifiable when your workflow benefits from it.

    If you just need lightweight runtime configuration changes, Unity offers a remote configuration package, and others do it too such as Firebase and Leanplum.
     
  6. SeerSucker69

    SeerSucker69

    Joined:
    Mar 6, 2021
    Posts:
    65
    Have you checked the Unity Assets store for addons?
     
  7. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    288