无法转换类型' OfficeOpenXml.ExcelRange'的对象输入' Microsoft.Office.Interop.Excel.Range'

时间:2018-01-13 14:30:00

标签: c#

我正在尝试将下拉列表添加到excel中。我是第一次这样做。

任何人都可以告诉我为什么会收到错误吗?

错误:

  

无法转换类型' OfficeOpenXml.ExcelRange'输入' Microsoft.Office.Interop.Excel.Range'

以下是代码:

            var cell1 = (Range)workSheet.Cells[4,4];


            cell1.Validation.Delete();
            cell1.Validation.Add(
               XlDVType.xlValidateList,
               XlDVAlertStyle.xlValidAlertInformation,
               XlFormatConditionOperator.xlBetween,
               List,
               Type.Missing);

            cell1.Validation.IgnoreBlank = true;
            cell1.Validation.InCellDropdown = true;

0 个答案:

没有答案