Export with Validation

Posted by: GEPHILLIPS on 21 March 2018, 4:03 am EST

    • Post Options:
    • Link

    Posted 21 March 2018, 4:03 am EST

    I am using Spread.NET 10.

    I need to export from a Spread.

    I need to set a cells with validation.

    This sheet will be used later to import back into my application but only with validated choices.

    From MS Excel I would use “Data Validation” with a list.

    How can I accomplish the same when the Spread is exported?

  • Posted 22 March 2018, 5:17 pm EST

    Hello,

    The earlier post was deleted since it was not relevant to ASP.NET. You can directly export the Spread sheet to Excel with all the Combobox items. This is exported as validation list to Excel.

    When you import you can choose to only import the Data shown in the validation cells and not validation list.

    For example you can use the following approach:

    
      protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    string[] cbstr;
                    cbstr = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" };
                    FarPoint.Web.Spread.ComboBoxCellType cmbbx = new FarPoint.Web.Spread.ComboBoxCellType(cbstr);
                    FpSpread1.ActiveSheetView.Columns[1].CellType = cmbbx;
                    FpSpread1.ActiveSheetView.Cells[0, 0, 2, 0].Text = "Test";
                }
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                FpSpread1.SaveExcel("C:\\Data\\excelfile.xlsx",FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat);
             
            }
    
            protected void Button2_Click(object sender, EventArgs e)
            {
                FpSpread1.Reset();
                FpSpread1.OpenExcel("C:\\Data\\excelfile.xlsx", FarPoint.Excel.ExcelOpenFlags.ComboDataOnly | FarPoint.Excel.ExcelOpenFlags.TruncateEmptyRowsAndColumns);
    
            }
    
    

    Please refer to the sample application attached.

    Thanks,

    Deepak Sharma

    SpreadWebexportExcelWithCombo.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels