2013-02-15 120 views
0

我想要獲取for循環中指定的值,然後將它們用作從Excel中獲取單元格的範圍。這裏出了什麼問題?如何獲取Excel的單元格的範圍爲循環

List<string> str = new List<string>(); 

     // The follwing increments by 4, and starts at 25 

     for (int i = 25; i <= lastRow; i += 4) // += means a + b 
     { 
      str = ws.Range["B"+i].Value; 
     } 

...

SeriesCollection seriesCollection_mySeries = xlChart.SeriesCollection(); 
Series series1 = seriesCollection_mySeries.NewSeries(); 

series1.Values = str 

;

+0

是WS值的'list'? – Sayse 2013-02-15 15:03:39

+0

有什麼問題? – Melanie 2013-02-15 15:05:20

+0

你能詳細說明你的問題是什麼嗎?我不明白你想要完成什麼 – Robert 2013-02-15 15:09:21

回答

0

我覺得你的問題應該予以澄清,但是這可能幫助:

for (int i = 25; i <= lastRow; i += 4) // += means a + b 
{ 
    string cellName = "B" + i.ToString(); 
    string cellValue = (string)ws.Range[cellName].Value; 
    str.Add(cellValue); 
} 
相關問題