How to read excel file from user and generating Google Sheet file

白昼怎懂夜的黑 提交于 2021-02-11 15:39:26

问题


I need to allow user upload excel (xlsx) file and then generate a Google Sheets file using Google Scripts (the generated file uses the input file values, process them with certain formulas and provides another excel file as output based on all processing)

I am currently doing the task in a simple desktop application (using MS Excel etc.), but problem is I have admin rights and I want other people to do the same on their PCs but they dont have admin rights, so please help me with this, whats the best way I can implement it via Google Sheets. I need following to do:

  • Get an XLSX file from user
  • Read two columns using google sheet script.
  • Process the read values and create a new google sheet file with 6/7 columns

Plz help as I am not looking for a ready made code but a head start, as I have never worked with google scripts before.


回答1:


  • First you need to study the basics of Apps Script in general, and of the SpreadsheetApp, DriveApp and Advanced Drive Service in specific.
  • The steps to write your code would be
    • retrieving the excel file on your Google Drive
    • retrieving its blob
    • creating a new file of the mimeType GOOGLE_SHEETS with the contents of your blob
    • Once you create a Google Spreadsheet - process it with the SpreadsheetApp methods to delete spare contents/ create a copy with only the desired contents.

Here you can find useful samples.

Note: It might make sense to retrieve the columns of interest before converting them to Google Sheets, but this is not something you can do with Apps Script or a Google API since they do not have methods to edit Excel files.



来源:https://stackoverflow.com/questions/59574242/how-to-read-excel-file-from-user-and-generating-google-sheet-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!