问题
I'm creating Excel files using AutomationFactory.CreateObject("Excel.Application")
.
I'm using these lines of codes to create a dropdown list:
mySheet.Range("A1").Validation.Add(Type:=Interop.Excel.XlDVType.xlValidateList, _
AlertStyle:=Interop.Excel.XlDVAlertStyle.xlValidAlertStop, _
[Operator]:=Interop.Excel.XlFormatConditionOperator.xlBetween,
Formula1:="=List!$C$3:$C$903")
The formula (Formula1:="=List!$C$3:$C$903") returns 900 rows
In Excel 2010 it works perfectly, however, in Excel 2003 no dropdownlist are created on the cell
Any alternative ways?
回答1:
In order to create a dropdown list from another sheet in Excel, you have to create a named range and then declare the named range in the Validation formula.
See this tutorial on how to do it from scratch.
来源:https://stackoverflow.com/questions/7805207/how-to-create-dropdownlist-on-excel-2003