我想使用C#获取Excel单元格的背景颜色,但是我找不到方法。
which library shall I use ?
microsoft.office.tools.excel.workbook.aspx
ormicrosoft.office.interop.excel
? what's the differents?I have tried following code but get no luck:
using Excel = Microsoft.Office.Interop.Excel; private void button1_Click(object sender, EventArgs e) { ofd.Filter = "xlsx|*.xlsx|xls|*.xls"; if(ofd.ShowDialog() == DialogResult.OK) { textBox2.Text = ofd.FileName; Excel.Application excel = new Excel.Application(); Excel.Workbook wb = excel.Workbooks.Open(textBox2.Text); Excel.Worksheet ws = wb.Sheets[1]; Excel.Range xlRange = ws.Cells[0, 0]; Debug.WriteLine("===" + xlRange.Interior.Color); } }