画像の配置

シート上に任意の画像ファイルを配置することができます。また、シート上の画像はExcelファイルのインポート/エクスポートにも対応します。
 ABCDEFG
1       
2       
3       
4       
5       
6       
7       
   

ソースコード

別ウィンドウで表示

using FarPoint.Web.Chart;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class picture : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }

        // SPREADの設定
        InitSpread(FpSpread1);

        // シート設定
        InitSpreadStyles(FpSpread1.Sheets[0]);
    }

    private void InitSpread(FarPoint.Web.Spread.FpSpread spread)
    {
        spread.CssClass = "spreadStyle2";
        spread.UseClipboard = false;
    }

    private void InitSpreadStyles(FarPoint.Web.Spread.SheetView sheet)
    {
        // 行列の設定
        sheet.RowCount = 7;
        sheet.ColumnCount = 7;
        sheet.PageSize = 25;

        // フォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Point(9);
        sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Point(9);
        sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Point(9);
        sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Point(9);

        FarPoint.Web.Spread.SpreadImage image = new FarPoint.Web.Spread.SpreadImage();
        image.CanMove = true;
        image.CanSelect = true;
        image.ImageUrl = "fplogo.png";
        image.Width = 200;
        image.Height = 30;
        image.Left = 50;
        image.Top = 50;
        sheet.Images.Add(image);
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        FpSpread1.SaveExcelToResponse("SpreadImageExport.xlsx", FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat);
    }
}
Imports FarPoint.Web.Chart
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Partial Public Class picture
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs)
        If IsPostBack Then
            Return
        End If

        ' SPREADの設定
        InitSpread(FpSpread1)

        ' シート設定
        InitSpreadStyles(FpSpread1.Sheets(0))
    End Sub

    Private Sub InitSpread(spread As FarPoint.Web.Spread.FpSpread)
        spread.CssClass = "spreadStyle2"
        spread.UseClipboard = False
    End Sub

    Private Sub InitSpreadStyles(sheet As FarPoint.Web.Spread.SheetView)
        ' 行列の設定
        sheet.RowCount = 7
        sheet.ColumnCount = 7
        sheet.PageSize = 25

        ' フォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Point(9)
        sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Point(9)
        sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Point(9)
        sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Point(9)

        Dim image As New FarPoint.Web.Spread.SpreadImage()
        image.CanMove = True
        image.CanSelect = True
        image.ImageUrl = "fplogo.png"
        image.Width = 200
        image.Height = 30
        image.Left = 50
        image.Top = 50
        sheet.Images.Add(image)
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        FpSpread1.SaveExcelToResponse("SpreadImageExport.xlsx", FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat)
    End Sub
End Class

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="picture.aspx.cs" Inherits="picture" %>

<%@ Register Assembly="FarPoint.Web.SpreadJ" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder1" runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" Height="250px">
        <CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
            ButtonShadowColor="ControlDark">
        </CommandBar>
        <Sheets>
            <FarPoint:SheetView SheetName="Sheet1">
            </FarPoint:SheetView>
        </Sheets>
    </FarPoint:FpSpread>
    <asp:Button ID="Button1" runat="server" Style="margin-top: 10px" OnClick="Button1_Click" Width="105px" Height="30px" Text="エクスポート" />
</asp:Content>