ExcelCreator 10.0 for .NET - ASP.NET デモ

ファイル作成(新規作成)

ExcelCreator 10.0 for .NET では、「Excel ファイルオープン(新規作成)」、「値の設定」、「ファイルクローズ」の 3 ステップで Excel ファイルを作成します。
以下のデモでは、明細書デザインの Excel ファイルを新規に作成する動作をご確認頂くことが可能です。

 

サンプルコード

  • VB.NET
  • C#
  • Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        InitializeComponent()
    End Sub
    Private Sub InitializeComponent()
        ' ExcelCreator インスタンス生成
        Me.components = New System.ComponentModel.Container()
        Me.Creator1 = New Creator(Me.components)
    End Sub
    Protected Sub ButtonCreate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonCreate.Click
        '【1】Excel ファイル新規作成
        Creator1.CreateBook(fileName, 1, xlsxVersion.ver2013)

        '【2】値の設定
        Creator1.DefaultFontName = "メイリオ" ' デフォルトフォント
        Creator1.DefaultFontPoint = 10        ' デフォルトフォントポイント
        Creator1.SheetName = "商品売上明細書" ' シート名
        ' 行の高さ、列幅の調整
        Creator1.Cell("1").RowHeight = 30
        Creator1.Cell("2").RowHeight = 15
        Creator1.Cell("3").RowHeight = 18
        Creator1.Cell("4:12").RowHeight = 15
        Creator1.Cell("A").ColWidth = 1.88
        Creator1.Cell("B:R").ColWidth = 3.13
        Creator1.Cell("S").ColWidth = 1.88
        ' 値、書式設定
        Creator1.Cell("B1").Value = "商品売上明細書"
        Creator1.Cell("B1:R1").Attr.MergeCells = True
        Creator1.Cell("B1").Attr.FontPoint = 18
        Creator1.Cell("B1").Attr.FontStyle = AdvanceSoftware.ExcelCreator.FontStyle.Bold
        Creator1.Cell("B1").Attr.HorizontalAlignment = HorizontalAlignment.Center
        Creator1.Cell("B1").Attr.FontColor2 = xlColor.White
        Creator1.Cell("B1").Attr.BackColor = Color.FromArgb(91, 155, 213)
        Creator1.Cell("B3").Value = "商品名"
        Creator1.Cell("B3:G3").Attr.MergeCells = True
        Creator1.Cell("H3").Value = "数量"
        Creator1.Cell("H3:J3").Attr.MergeCells = True
        Creator1.Cell("K3").Value = "単価"
        Creator1.Cell("K3:N3").Attr.MergeCells = True
        Creator1.Cell("O3").Value = "金額"
        Creator1.Cell("O3:R3").Attr.MergeCells = True
        Creator1.Cell("B3:R3").Attr.HorizontalAlignment = HorizontalAlignment.Center
        Creator1.Cell("B3:R3").Attr.FontColor2 = xlColor.White
        Creator1.Cell("B4:G4").Attr.MergeCells = True
        Creator1.Cell("H4:J4").Attr.MergeCells = True
        Creator1.Cell("K4:N4").Attr.MergeCells = True
        Creator1.Cell("O4:R4").Attr.MergeCells = True
        For i As Integer = 0 To 4
            Creator1.RowCopy(3, 4 + i)
        Next
        Creator1.Cell("B3:R3").Attr.BackColor = Color.FromArgb(91, 155, 213)
        Creator1.Cell("B3:R9").Attr.Box(BoxType.Ltc, BorderStyle.Thin, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B3:R9").Attr.Box(BoxType.Box, BorderStyle.Medium, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B4").Value = "ExcelCreator 2016"
        Creator1.Cell("H4").Value = 10
        Creator1.Cell("K4").Value = 64000
        Creator1.Cell("O4").Func("=H4*K4", Nothing)
        Creator1.Cell("B5").Value = "VB-Report 8"
        Creator1.Cell("H5").Value = 8
        Creator1.Cell("K5").Value = 85000
        Creator1.Cell("O5").Func("=H5*K5", Nothing)
        Creator1.Cell("B6").Value = "ExcelWebForm"
        Creator1.Cell("H6").Value = 5
        Creator1.Cell("K6").Value = 70000
        Creator1.Cell("O6").Func("=H6*K6", Nothing)
        Creator1.Cell("K4:N9").Attr.Format = "#,##0_ "
        Creator1.Cell("O4:R9").Attr.Format = """\""#,##0;[赤]""\""#,##0"
        Creator1.Cell("B4:R4").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B5:R5").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B5:R5").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B6:R6").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B6:R6").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B7:R7").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B7:R7").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B8:R8").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B8:R8").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B9:R9").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213))
        Creator1.Cell("B5:R5").Attr.BackColor = Color.FromArgb(221, 235, 247)
        Creator1.Cell("B7:R7").Attr.BackColor = Color.FromArgb(221, 235, 247)
        Creator1.Cell("B9:R9").Attr.BackColor = Color.FromArgb(221, 235, 247)
        Creator1.Cell("K10:N10").Attr.MergeCells = True
        Creator1.Cell("K10:N10").Attr.HorizontalAlignment = HorizontalAlignment.Center
        Creator1.Cell("K10:N10").Attr.FontColor2 = xlColor.White
        Creator1.Cell("K10:N10").Attr.BackColor = Color.FromArgb(91, 155, 213)
        Creator1.Cell("O10:R10").Attr.MergeCells = True
        Creator1.Cell("O10:R10").Attr.Format = """¥""#,##0;[赤]""\""#,##0"
        Creator1.Cell("K10:R10").Attr.Box(BoxType.Ltc, BorderStyle.Thin, Color.FromArgb(91, 155, 213))
        Creator1.Cell("K10:R10").Attr.Box(BoxType.Box, BorderStyle.Medium, Color.FromArgb(91, 155, 213))
        For i As Integer = 0 To 1
            Creator1.RowCopy(9, 10 + i)
        Next
        Creator1.Cell("K10").Value = "小計"
        Creator1.Cell("O10").Func("=SUM(O4:R8)", Nothing)
        Creator1.Cell("K11").Value = "消費税"
        Creator1.Cell("O11").Func("=O10*0.08", Nothing)
        Creator1.Cell("K12").Value = "合計"
        Creator1.Cell("O12").Func("=O10+O11", Nothing)

        '【3】Excel ファイルクローズ
        Creator1.CloseBook(True)
    End Sub
  • protected void Page_Load(object sender, EventArgs e)
    {
        InitializeComponent();
    }
    private void InitializeComponent()
    {
        // ExcelCreator インスタンス生成
        this.components = new System.ComponentModel.Container();
        this.creator1 = new Creator(this.components);
    }
    protected void ButtonCreate_Click(object sender, EventArgs e)
    {
        //【1】Excel ファイル新規作成
        creator1.CreateBook(fileName, 1, xlsxVersion.ver2013);

        //【2】値の設定
        creator1.DefaultFontName = "メイリオ";  // デフォルトフォント
        creator1.DefaultFontPoint = 10;         // デフォルトフォントポイント
        creator1.SheetName = "商品売上明細書";  // シート名
        // 行の高さ、列幅の調整
        creator1.Cell("1").RowHeight = 30;
        creator1.Cell("2").RowHeight = 15;
        creator1.Cell("3").RowHeight = 18;
        creator1.Cell("4:12").RowHeight = 15;
        creator1.Cell("A").ColWidth = 1.88;
        creator1.Cell("B:R").ColWidth = 3.13;
        creator1.Cell("S").ColWidth = 1.88;
        // 値、書式設定
        creator1.Cell("B1").Value = "商品売上明細書";
        creator1.Cell("B1:R1").Attr.MergeCells = true;
        creator1.Cell("B1").Attr.FontPoint = 18;
        creator1.Cell("B1").Attr.FontStyle = AdvanceSoftware.ExcelCreator.FontStyle.Bold;
        creator1.Cell("B1").Attr.HorizontalAlignment = HorizontalAlignment.Center;
        creator1.Cell("B1").Attr.FontColor2 = xlColor.White;
        creator1.Cell("B1").Attr.BackColor = Color.FromArgb(91, 155, 213);
        creator1.Cell("B3").Value = "商品名";
        creator1.Cell("B3:G3").Attr.MergeCells = true;
        creator1.Cell("H3").Value = "数量";
        creator1.Cell("H3:J3").Attr.MergeCells = true;
        creator1.Cell("K3").Value = "単価";
        creator1.Cell("K3:N3").Attr.MergeCells = true;
        creator1.Cell("O3").Value = "金額";
        creator1.Cell("O3:R3").Attr.MergeCells = true;
        creator1.Cell("B3:R3").Attr.HorizontalAlignment = HorizontalAlignment.Center;
        creator1.Cell("B3:R3").Attr.FontColor2 = xlColor.White;
        creator1.Cell("B4:G4").Attr.MergeCells = true;
        creator1.Cell("H4:J4").Attr.MergeCells = true;
        creator1.Cell("K4:N4").Attr.MergeCells = true;
        creator1.Cell("O4:R4").Attr.MergeCells = true;
        for (int i = 0; i < 5; i++)
        {
            creator1.RowCopy(3, 4 + i);
        }
        creator1.Cell("B3:R3").Attr.BackColor = Color.FromArgb(91, 155, 213);
        creator1.Cell("B3:R9").Attr.Box(BoxType.Ltc, BorderStyle.Thin, Color.FromArgb(91, 155, 213));
        creator1.Cell("B3:R9").Attr.Box(BoxType.Box, BorderStyle.Medium, Color.FromArgb(91, 155, 213));
        creator1.Cell("B4").Value = "ExcelCreator 2016";
        creator1.Cell("H4").Value = 10;
        creator1.Cell("K4").Value = 64000;
        creator1.Cell("O4").Func("=H4*K4", null);
        creator1.Cell("B5").Value = "VB-Report 8";
        creator1.Cell("H5").Value = 8;
        creator1.Cell("K5").Value = 85000;
        creator1.Cell("O5").Func("=H5*K5", null);
        creator1.Cell("B6").Value = "ExcelWebForm";
        creator1.Cell("H6").Value = 5;
        creator1.Cell("K6").Value = 70000;
        creator1.Cell("O6").Func("=H6*K6", null);
        creator1.Cell("K4:N9").Attr.Format = "#,##0_ ";
        creator1.Cell("O4:R9").Attr.Format = @"¥#,##0;[赤]\#,##0";
        creator1.Cell("B4:R4").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B5:R5").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B5:R5").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B6:R6").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B6:R6").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B7:R7").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B7:R7").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B8:R8").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B8:R8").Attr.LineBottom(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B9:R9").Attr.LineTop(BorderStyle.Dotted, Color.FromArgb(91, 155, 213));
        creator1.Cell("B5:R5").Attr.BackColor = Color.FromArgb(221, 235, 247);
        creator1.Cell("B7:R7").Attr.BackColor = Color.FromArgb(221, 235, 247);
        creator1.Cell("B9:R9").Attr.BackColor = Color.FromArgb(221, 235, 247);
        creator1.Cell("K10:N10").Attr.MergeCells = true;
        creator1.Cell("K10:N10").Attr.HorizontalAlignment = HorizontalAlignment.Center;
        creator1.Cell("K10:N10").Attr.FontColor2 = xlColor.White;
        creator1.Cell("K10:N10").Attr.BackColor = Color.FromArgb(91, 155, 213);
        creator1.Cell("O10:R10").Attr.MergeCells = true;
        creator1.Cell("O10:R10").Attr.Format = @"¥#,##0;[赤]\#,##0";
        creator1.Cell("K10:R10").Attr.Box(BoxType.Ltc, BorderStyle.Thin, Color.FromArgb(91, 155, 213));
        creator1.Cell("K10:R10").Attr.Box(BoxType.Box, BorderStyle.Medium, Color.FromArgb(91, 155, 213));
        for (int i = 0; i < 2; i++)
        {
            creator1.RowCopy(9, 10 + i);
        }
        creator1.Cell("K10").Value = "小計";
        creator1.Cell("O10").Func("=SUM(O4:R8)", null);
        creator1.Cell("K11").Value = "消費税";
        creator1.Cell("O11").Func("=O10*0.08", null);
        creator1.Cell("K12").Value = "合計";
        creator1.Cell("O12").Func("=O10+O11", null);

        //【3】Excel ファイルクローズ
        creator1.CloseBook(true);
    }

ファイル作成(オーバーレイ/上書き)

既存の Excel ファイルに値を追加し新しい Excel ファイルを作成する「オーバーレイ機能」、ならびに、「上書きオープン」に対応します。
以下のデモでは、「オーバーレイ機能」で Excel ファイルを作成する動作をご確認頂くことが可能です。

 

サンプルコード

  • VB.NET
  • C#
  • Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        InitializeComponent()
    End Sub
    Private Sub InitializeComponent()
        ' ExcelCreator インスタンス生成
        Me.components = New System.ComponentModel.Container()
        Me.Creator1 = New Creator(Me.components)
    End Sub
    Protected Sub ButtonOverlay_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonOverlay.Click
        '【1】オーバーレイオープン
        Creator1.OpenBook(fileName, templateName)

        '【2】値の設定
        Creator1.Cell("B4").Value = "ExcelCreator 2016"
        Creator1.Cell("H4").Value = 10
        Creator1.Cell("K4").Value = 64000
        Creator1.Cell("O4").Func("=H4*K4", Nothing)
        Creator1.Cell("B5").Value = "VB-Report 8"
        Creator1.Cell("H5").Value = 8
        Creator1.Cell("K5").Value = 85000
        Creator1.Cell("O5").Func("=H5*K5", Nothing)
        Creator1.Cell("B6").Value = "ExcelWebForm"
        Creator1.Cell("H6").Value = 5
        Creator1.Cell("K6").Value = 70000
        Creator1.Cell("O6").Func("=H6*K6", Nothing)
        Creator1.Cell("O10").Func("=SUM(O4:R8)", Nothing)
        Creator1.Cell("O11").Func("=O10*0.08", Nothing)
        Creator1.Cell("O12").Func("=O10+O11", Nothing)

        '【3】Excel ファイルクローズ
        Creator1.CloseBook(True)
    End Sub
  • protected void Page_Load(object sender, EventArgs e)
    {
        InitializeComponent();
    }
    private void InitializeComponent()
    {
        // ExcelCreator インスタンス生成
        this.components = new System.ComponentModel.Container();
        this.creator1 = new Creator(this.components);
    }
    protected void ButtonOverlay_Click(object sender, EventArgs e)
    {
        //【1】オーバーレイオープン
        creator1.OpenBook(fileName, templateName);

        //【2】値の設定
        creator1.Cell("B4").Value = "ExcelCreator 2016";
        creator1.Cell("H4").Value = 10;
        creator1.Cell("K4").Value = 64000;
        creator1.Cell("O4").Func("=H4*K4", null);
        creator1.Cell("B5").Value = "VB-Report 8";
        creator1.Cell("H5").Value = 8;
        creator1.Cell("K5").Value = 85000;
        creator1.Cell("O5").Func("=H5*K5", null);
        creator1.Cell("B6").Value = "ExcelWebForm";
        creator1.Cell("H6").Value = 5;
        creator1.Cell("K6").Value = 70000;
        creator1.Cell("O6").Func("=H6*K6", null);
        creator1.Cell("O10").Func("=SUM(O4:R8)", null);
        creator1.Cell("O11").Func("=O10*0.08", null);
        creator1.Cell("O12").Func("=O10+O11", null);

        //【3】Excel ファイルクローズ
        creator1.CloseBook(true);
    }

ファイル作成(PDF/HTML)

生成した Excel ファイルを基に、PDF/HTML ファイルの出力にも対応します。

サンプルコード

  • VB.NET
  • C#
  • Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        InitializeComponent()
    End Sub
    Private Sub InitializeComponent()
        ' ExcelCreator インスタンス生成
        Me.components = New System.ComponentModel.Container()
        Me.Creator1 = New Creator(Me.components)
    End Sub
    Protected Sub ButtonCreate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonCreate.Click
        '【1】オーバーレイオープン
        Creator1.OpenBook(fileName, templateName)

        '【2】値の設定
        Creator1.Cell("B4").Value = "ExcelCreator 2016"
        Creator1.Cell("H4").Value = 10
        Creator1.Cell("K4").Value = 64000
        Creator1.Cell("O4").Func("=H4*K4", 640000)
        Creator1.Cell("B5").Value = "VB-Report 8"
        Creator1.Cell("H5").Value = 8
        Creator1.Cell("K5").Value = 85000
        Creator1.Cell("O5").Func("=H5*K5", 680000)
        Creator1.Cell("B6").Value = "ExcelWebForm"
        Creator1.Cell("H6").Value = 5
        Creator1.Cell("K6").Value = 70000
        Creator1.Cell("O6").Func("=H6*K6", 350000)
        Creator1.Cell("O10").Func("=SUM(O4:R8)", 1670000)
        Creator1.Cell("O11").Func("=O10*0.08", 133600)
        Creator1.Cell("O12").Func("=O10+O11", 1803600)
                
        '【3】Excel ファイルクローズ、PDF 出力
        Creator1.CloseBook(True, pdfFileName, True)

        ' HTML 出力の場合
        'Creator1.CloseBook(True, "", htmlFileName, True)
    End Sub
  • protected void Page_Load(object sender, EventArgs e)
    {
        InitializeComponent();
    }
    private void InitializeComponent()
    {
        // ExcelCreator インスタンス生成
        this.components = new System.ComponentModel.Container();
        this.creator1 = new Creator(this.components);
    }
    protected void ButtonCreate_Click(object sender, EventArgs e)
    {
        //【1】オーバーレイオープン
        creator1.OpenBook(fileName, templateName);

        //【2】値の設定
        creator1.Cell("B4").Value = "ExcelCreator 2016";
        creator1.Cell("H4").Value = 10;
        creator1.Cell("K4").Value = 64000;
        creator1.Cell("O4").Func("=H4*K4", 640000);
        creator1.Cell("B5").Value = "VB-Report 8";
        creator1.Cell("H5").Value = 8;
        creator1.Cell("K5").Value = 85000;
        creator1.Cell("O5").Func("=H5*K5", 680000);
        creator1.Cell("B6").Value = "ExcelWebForm";
        creator1.Cell("H6").Value = 5;
        creator1.Cell("K6").Value = 70000;
        creator1.Cell("O6").Func("=H6*K6", 350000);
        creator1.Cell("O10").Func("=SUM(O4:R8)", 1670000);
        creator1.Cell("O11").Func("=O10*0.08", 133600);
        creator1.Cell("O12").Func("=O10+O11", 1803600);

        //【3】Excel ファイルクローズ、PDF 出力
        creator1.CloseBook(true, pdfFileName, true);

        // HTML 出力の場合
        //creator1.CloseBook(true, "", htmlFileName, true);
    }