固定セル

固定セル

機能

Settings


エクスポート
エクスポート名:

Description

このサンプルでは、固定セルを含む MVC FlexGrid を Excel ファイルにエクスポートする方法を示します。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApiExplorer.Models;

namespace WebApiExplorer.Controllers
{
    public partial class MVCFlexGridController : Controller
    {
        private readonly GridExportImportOptions _flexGridFrozenCellsModel = new GridExportImportOptions
        {
            NeedExport = true,
            NeedImport = false,
            IncludeColumnHeaders = true
        };

        public ActionResult FrozenCells()
        {
            ViewBag.Options = _flexGridFrozenCellsModel;
            ViewBag.DemoSettingsModel = new ClientSettingsModel
            {
                Settings = new Dictionary<string, object[]>
                {
                    {"FrozenColumns", new object[]{1, 0, 2, 3}},
                    {"FrozenRows", new object[]{2, 0, 1, 3, 4, 5}}
                },
                HeaderNames = new Dictionary<string, string> 
                {
                    {"FrozenColumns", Resources.MVCFlexGrid.FrozenCells_FrozenColumns},
                    {"FrozenRows", Resources.MVCFlexGrid.FrozenCells_FrozenRows}
                }
            };
            return View(Sale.GetData(100));
        }
    }
}
@using WebApiExplorer.Models
@using C1.Web.Mvc.Grid
@model IEnumerable<Sale>
@{
    ClientSettingsModel demoSettingsModel = ViewBag.DemoSettingsModel;
    GridExportImportOptions optionsModel = ViewBag.Options;
    ViewBag.DemoSettings = true;
}

@(Html.C1().FlexGrid<Sale>().Id(optionsModel.ControlId)
    .AutoGenerateColumns(false)
    .IsReadOnly(true)
    .Bind(Model)
    .CssClass("grid")
    .Columns(columns =>
    {
        columns.Add(column => column.Binding("ID"));
        columns.Add(column => column.Binding("Start").Format("MMM d yy"));
        columns.Add(column => column.Binding("End").Format("HH:mm"));
        columns.Add(column => column.Binding("Country"));
        columns.Add(column => column.Binding("Product"));
        columns.Add(column => column.Binding("Color"));
        columns.Add(column => column.Binding("Amount").Format("c"));
        columns.Add(column => column.Binding("Amount2").Format("c"));
        columns.Add(column => column.Binding("Discount").Format("p0"));
        columns.Add(column => column.Binding("Active"));
    })
    .FrozenColumns(1)
    .FrozenRows(2)
)

@section Settings{
    @Html.Partial("_FlexGridOptions", optionsModel)
}

@section Description{
    @Html.Raw(Resources.MVCFlexGrid.FrozenCells_Text0)
}