简体   繁体   English

尝试使用PHP或Javascript从Google表格中提取值

[英]Trying to pull values from a Google Sheet using PHP or Javascript

I have a Google Sheets spreadsheet containing product inventory. 我有一个包含产品库存的Google表格电子表格。 There are multiple sheets within the document, each sheet containing products of a particular brand. 文档中有多张纸,每张纸都包含特定品牌的产品。 The two important columns in each sheet that I'd like to be able to work with are Part Number, and Quantity. 我希望能够使用的每个工作表中的两个重要列是零件号和数量。

What I want to be able to do in my web app is, given a particular part number and brand name, look up the corresponding quantity in the correct sheet in my Google Sheets document, and send that value back to to the web app to display. 我想要在网络应用程序中执行的操作是,给定特定的部件号和品牌名称,在我的Google表格文档中的正确工作表中查找相应的数量,然后将该值发送回网络应用程序以进行显示。 (Essentially, I want the web app user to be able to click on a part number, and get the current quantity of that item displayed next to it.) (本质上,我希望Web应用程序用户能够单击部件号,并获取显示在其旁边的该项目的当前数量。)

I've tried publishing the Google Sheets document to the web, and accessing it in PHP as several of the formats Google offers (csv, xlsx, and ods) and have hit a wall in each instance: 我尝试过将Google表格文档发布到网络上,并以PHP的形式使用Google提供的几种格式(csv,xlsx和ods)进行访问,但在每种情况下都遇到了麻烦:

  • CSV only lets me access the first sheet in the document CSV仅允许我访问文档中的第一张纸
  • XLSX isn't readable by the PHP class I tried using (excel_reader.php, which I use for other things and is otherwise perfect but I guess can only read XLS, not XLSX) 我尝试使用的PHP类无法读取XLSX(excel_reader.php,我用于其他用途,它本来很完美,但我想只能读取XLS,而不能读取XLSX)
  • ODS has its own PHP class as well, but it seems overly complex and unwieldy for what I'm trying to do ODS也有自己的PHP类,但是对于我想做的事情来说似乎过于复杂和笨拙

I don't need to modify the Google Sheet in any way with this... all I need to do is go, "Given brand X and part number Y, return the value in the Quantity column of this Google Sheet." 我不需要以此方式进行任何修改。我要做的就是,“给出品牌X和部件号Y,在此Google表格的数量列中返回值”。 I'm really hoping there's a (fairly) simple way to do this... 我真的希望有一种(相当)简单的方法来做到这一点...

I recommend using this Google Spreadsheets Client API . 我建议使用此Google Spreadsheets Client API

It makes the dirty work quite simple and provides a relatively easy-to-use interface so you can work with your spreadsheets without "workarounds". 它使肮脏的工作变得非常简单,并提供了一个相对易于使用的界面,因此您可以使用电子表格而无需“替代方法”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用javascript的for循环从Google表格中提取数据? - Pull data from a google sheet with a for loop with javascript? 使用JavaScript PHP jQuery将网页中的数据发布到Google表格 - Posting data from webpage using JavaScript PHP jQuery to Google Sheet 使用 Google Apps Script 和 JavaScript 从 Google 表格中反映 HTML 中的选项值 - Reflect the Option Values in HTML from google sheet using Google Apps Script and JavaScript 尝试使用AJAX将变量值从JavaScript传递到PHP - Trying to pass variable values from JavaScript to PHP using AJAX 使用 Google Apps 脚本添加/更新 Google 工作表行数据比较 HTML 表单中的值 - 尝试在工作表上查找匹配项并更新所选行数据 - Add/Update Google Sheet Row Data Comparing Values from HTML Form Using Google Apps Script - Trying to Find Match on Sheet & Update Selected Row Data 查找并替换Java脚本需要从Excel工作表中提取值,但是循环并输出 - Find and Replace Javascript Needs to pull values from an excel sheet, loop though, and output 将Gmail拉入Google表格 - Pull Gmails into a Google Sheet 使用DOMDOCUMENT拉取JavaScript值 - Using DOMDOCUMENT to pull JavaScript values 使用Javascript的范围功能从Google表格中提取 - Using Javascript's range feature to pull from Google Sheets 在JavaScript中使用PHP中的值 - Using values from PHP in JavaScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM