本文介绍了使用javascript从excel电子表格中读取数据的最简单的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  +  - ----- + ---------------------------------------- + --- ---------------- + 
|代码|机场名称|位置|
+ ------- + ------------------------------------- --- + ------------------- +
| AUA | Beatrix国际机场|奥拉涅斯塔德,阿鲁巴|
+ ------- + ------------------------------------- --- + ------------------- +

我的Javascript传递了一个3字符的字符串,应该是一个航空公司的代码。当这种情况发生时,我需要在电子表格上找到代码,并返回机场名称和位置。



我想到像:

  var code =AUA; 

console.log(getAirportInfo(code));

函数getAirportInfo(code){

//从电子表格获取信息
//格式信息(无需帮助)

返回机场信息
}

日志会写出来:



阿鲁巴(AUA)Oranjestad:Beatrix国际机场



什么是最简单的方法从电子表格获取需要的数据?



额外信息:


  1. 该电子表格有超过17,000个条目

  2. 上面提到的函数最多可以调用8次。

  3. 我不必使用我现在所使用的Excel电子表格

  4. 我永远不需要使用我的代码编辑电子表格

我在网路上搜索,但是我可以找到的东西比我想要的那样复杂得多,所以很难理解我想要的东西。



感谢任何帮助指向正确的方向。

解决方案

p>我最后在shancarter.com/data_converter使用了一个工具将我的flie转换为JSON文件并将其链接到我的页面。现在我只是循环通过这个JSON对象来获得我需要的东西。这似乎是我特殊需要的最简单的方式。


I have a list of airport codes, names, and locations in an Excel Spreadsheet like the below:

+-------+----------------------------------------+-------------------+
|  Code |               Airport Name             |      Location     |
+-------+----------------------------------------+-------------------+
|  AUA  |   Queen Beatrix International Airport  |  Oranjestad, Aruba|
+-------+----------------------------------------+-------------------+

My Javascript is passed a 3 character string that should be an airline code. When that happens I need to find the code on the spreadsheet and return the Airport Name and Location.

Im thinking something like:

var code = "AUA";

console.log(getAirportInfo(code));

function getAirportInfo(code) {

// get information from spreadsheet
//format info (no help needed there)

return airportInfo;
}

Where the log would write out:

Oranjestad, Aruba (AUA): Queen Beatrix International Airport

What is the easiest method to get the data I need from the spreadsheet?

Extra Info:

  1. The spreadsheet has over 17,000 entries
  2. The function alluded to above may be called up to 8 times in row
  3. I don't have to use an Excel Spreadsheet thats just what I have now
  4. I will never need to edit the spreadsheet with my code

I did search around the web but everything I could find was much more complicated than what Im trying to do so it made it hard to understand what Im looking for.

Thank you for any help pointing me in the right direction.

解决方案

I ended up using a tool at shancarter.com/data_converter to convert my flie to a JSON file and linked that to my page. Now I just loop through that JSON object to get what I need. This seemed like the simplest way for my particular needs.

这篇关于使用javascript从excel电子表格中读取数据的最简单的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 12:14