簡體   English   中英

這是存儲來自excel的數據的最佳方法

[英]Which was the best way to store the data that was coming from excel

大家好,我已經寫了一個代碼從Excel中讀取Excel數據,但是我不知道哪種方法是將數據存儲在Excel中的最佳方法,如下所示

               2000-01       2001-02     2002-03    2003-04   2004-05

Some text        65%           52%          51.3%      *        6.1%
Some text        65%           52%          51.3%      *        6.1%
Some text        65%           52%          51.3%      *        6.1%
Some text        65%           52%          51.3%      *        6.1%
Some text        65%           52%          51.3%      *        6.1%

數據似乎是這樣的,在我的excel文件中,我知道如何檢索數據,但是我正在尋找存儲數據的最佳方法,有誰能幫到我

目前,我將數據存儲到List<string> ,如下所示

Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("A11", "G21");
System.Array myvalues = (System.Array)range.Cells.Value2;
List<string> newList = AnyListToStrList(myvalues);

但是我不確定這是正確的方法,所以我正在尋找更好的方法。

我將創建2個表:

main (
id int,
description varchar(255)
)

period
(
main_id int (fk main(id))
period int,
period_length int, --in months or years, whatever is more appropriate
period_value float
)

如果要將其存儲在數據庫中並在檢索數據時實際顯示excel文檔,建議您存儲文件本身,這只會減少Excel Automation附帶的麻煩,例如創建excel文件。

如果您打算從excel保存到數據庫,則我將使用盡可能接近最終da表的數據結構,以便能夠盡早發現問題。 例如,您可以使用具有與數據庫中相同的列名稱和類型的數據表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM