[問題] 請問如何將excel裡cell轉型?
請各位高手
我目前用C#來自動化控制excel
但有牽扯到計算及identify cell內的文字
所以我必需要將cells內轉型
程式碼如下:
_Application o_excel = null;
_Workbook o_book = null;
_Worksheet o_sheet = null;
o_excel = new Microsoft.Office.Interop.Excel.Application();
o_book = o_excel.Workbooks.Add();
o_excel.Visible = true;
o_excel.DisplayAlerts = true;
o_sheet = o_book.Worksheets[1];
o_sheet.Columns.ColumnWidth = 2;
o_sheet.Rows.RowHeight = 15;
o_sheet.Cells.Replace("S", "RC");
while (Convert.ToString((Microsoft.Office.Interop.Excel.Range)o_sheet.Cells[40 + n1 ,3].Text) =="RC")
{
n1++;
}
for (int i = 0; i <= 31; i++)
{
o_sheet.Cells[20, 68 - i] = o_sheet.Cells[41 + n1 + i, 10];
}
我實際compile後確出現下列錯誤
Additional information: Cannot convert type 'string' to 'Microsoft.Office.Interop.Excel.Range'
請問我該怎麼解決???
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.144.106
→
05/18 11:43, , 1F
05/18 11:43, 1F
→
05/18 11:46, , 2F
05/18 11:46, 2F
什麼意思...不太暸解??
※ 編輯: chrishappy11 來自: 219.70.144.106 (05/18 12:30)
→
05/19 14:28, , 3F
05/19 14:28, 3F
→
05/19 14:29, , 4F
05/19 14:29, 4F
其實我有試過value,value2 但一樣的錯誤訊息
※ 編輯: chrishappy11 來自: 119.14.168.8 (05/21 19:04)
→
05/24 22:12, , 5F
05/24 22:12, 5F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章