jexcel - 转置问题
我正在尝试使用 JExcel API 并有以下问题。
我已查询数据库表中的 3 列:id
、time
、value
。我将它们作为对象添加到不同的数组中。我想将它们输出到 Excel 工作表中,如下所示:
id 9:10 9:11 9:12 1 value value value 2 value value value 3 value value value
其中 1
、2
和 3
是 id。 value
是当时 id
的值。 我不知道如何将所有输入按上述方式排序,因为我需要进行进一步分析。
有什么建议吗?
I am trying to work with JExcel API and had the following question.
I have queried my database tables for 3 columns: id
, time
, value
. I am adding them into different arrays as objects. I want to output them into an excel sheet as follows:
id 9:10 9:11 9:12 1 value value value 2 value value value 3 value value value
Where 1
, 2
and 3
are the id's. The value
is the value of that id
at that time.
I am not getting a clue how I could have all the input sorted as above as I need to do it for further analysis.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此类问题可以相当容易地解决。
首先,问问自己,如果我手动转置它们,我会怎么做?
我假设数据库中的数据看起来像这样:
您需要做的是将行交换为列。 id<->id、1<->09:00、2<->09:11....valueA1<->valueA1、valueB1<->valueA2。
因此,如果我们使用嵌套的 for 循环来处理这个问题,我们在单元格 C 中读取内容,然后在 C_ij 处将其写入 C_ji。
我希望这足以告诉你该怎么做。
This sort of issue can be resolved reasonably easily.
First, ask yourself, what would I do if I were to transpose them by hand?
I'm assuming here your data in the DB looks liek this:
What you need to do, is swap your rows into columns. id <->id, 1<->09:00, 2<->09:11....valueA1<->valueA1, valueB1<->valueA2.
So, if we were going over this with nested for loops, where we read in a cell C, at C_ij we write out into C_ji.
I hope this enough to show you what to do.