2012-10-25 69 views
0

您好我不得不進口值輸入到Excel文件以下列方式:擅長值

值必須進口基礎上的每一行即00004100. 最後8個字設00004爲column5 100是第6列。

我需要爲每個唯一的column5和column6對將值導入單獨的Excel表單。即最後8位數字爲00002100的所有行都將放入一張Excel表格中,依此類推。

1234 john smith america 00002100 
1234 john smith america 00002100 
1234 john smith america 00002200 
1234 john smith america 00002200 
1234 john smith america 00003100 
1234 john smith america 00003200 
1234 john smith america 00003200 
1234 john smith america 00004100 
1234 john smith america 00002100 

如何根據vb中的給定條件生成excel表單?

Thanx提前!

+1

這個問題不是很清楚。你想使用VBA-Excel或VB.Net嗎?他們都不同... –

回答

0

我不確定爲什麼這是一個VB問題?你使用Interop嗎? 由於我不知道這一點,我使用僞代碼 - 但我認爲你會明白。 它更像vb.net - 如果你使用vba,一般的想法會起作用。

一般我會對以下內容:遍歷每一行,並集中一個新的字符串。 喜歡傾向:

For row = 0 to rows.count-1 
dim str as new stringbuilder() 


for col = 0 to rows(row).count-1 
    str.append(rows(row).item(col) 
next 

dim lasteight=str.tostring 
lasteight=lasteight.substring(lasteight.length-8) 

'here do the following: have a list of your sheetnames. If this list contains lasteight goto this page and append the row. if no sheet exist, create one and append as well. 
next 
+0

thnx! Ishall看看這個...... 我正在使用一個excel模板,每創建一個新的值列表就會被複制。然後使用open xml填充每個要生成的報告的值以及其他要合併的數據。 – chubhub