创建电子表格 [英] Creating a spreadsheet

查看:94
本文介绍了创建电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,它基本上只是一个在线电子表格.我一直在想我应该如何开始构建它.我的主要技术堆栈是 Rails,但我可以根据工作进行更改,尽管我更愿意至少保留 Rails 的后端(然后可能是主干前端?)

I have an application I'm building that is basically just an online spreadsheet. I've been wondering how I should start building this. My primary tech stack is with Rails, but I can change depending on the job, though I'd prefer to keep at least the backend with Rails (and then maybe a backbone frontend?)

尽管该应用程序不完全是电子表格,但用户将能够为列创建名称,而不是像在 Excel 中那样按 A、B、C 排列.例如,他们可以创建一个名为 Revenue 的列,并让第 1、2、3 行的值分别为 $1000$2000 3000 美元.用户还可以对列 ASC 或 DESC 进行排序.

The application isn't exactly a spreadsheet though, instead of columns going by A,B,C like they do in Excel, users will be able to create names for columns. So for example they could create a column called Revenue and have the rows 1,2,3 have values of $1000, $2000, and $3000. Users will also be able to sort the columns ASC or DESC.

我想过只拥有一个包含 30 个字段的 Mysql 表,其中 15 个是值,15 个是相应的列名.除了这不会是一种非常低效的方法吗?更不用说用户可以输入的列数必须有硬性限制.

I thought about just having a Mysql table with say 30 fields where 15 are the values, and 15 are the corresponding column names. Except won't this be an incredibly inefficient method? Not to mention there would have to be a hard limit on how many columns a user could put in.

那么有没有更好的方法呢?或者我刚刚描述的最好的方法.

So is there a better method? Or the method I just described the best way.

推荐答案

如果列"是问题域的核心部分,那么创建一个表来存储它们可能会很有用.电子表格通常有 tablescolumnsrowscells,它们之间有明确的关系(单元格属于列行、列和行属于表).这似乎很适合像 MySql 这样的关系数据存储.

If "columns" are a core part of your problem domain then it may be useful to create a table to store them. Spreadsheets usually have tables, columns, rows, and cells with well defined relationships between them (cells belong to columns and rows, columns and rows belong to tables). That seems like a natural fit to a relational data store like MySql.

您可以为列定义创建一个表,其中包含每列的索引、它所属表的外键以及该列的用户指定显示名称.

You could create a table for your column definitions which contains the index of each column, a foreign key to the table it belongs to, and the user-specified display name for that column.

这篇关于创建电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆