<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ジャナ・ビジネス・コンサルティング &#187; Spreadsheet</title>
	<atom:link href="http://www.janabiz.com/tag/spreadsheet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.janabiz.com</link>
	<description>新聞、電子出版、Webシステム開発 SAP ERP開発 人材派遣 Java Android プログラマ学校</description>
	<lastBuildDate>Sat, 04 Mar 2023 03:22:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>OpenXML Spreadsheet, how to copy and insert specified rows</title>
		<link>http://www.janabiz.com/openxml-copy-spreadsheet-rows/</link>
		<comments>http://www.janabiz.com/openxml-copy-spreadsheet-rows/#comments</comments>
		<pubDate>Mon, 13 May 2013 09:44:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Spreadsheet]]></category>
		<category><![CDATA[OpenXML]]></category>

		<guid isPermaLink="false">http://new.janabiz.com/?p=371</guid>
		<description><![CDATA[<p>We usually use OpenXML spreadsheet to create excel document and report. For some document and report, sometimes we hope copy and insert some rows or columns automatically. For example , we want to output a list data into excel worksheet whose element has 3 formatted rows including some merge cells etc. If list&#8217;s size is 10, we hope copy 3 formatted rows of first element 10 times and insert copied rows below the first element rows automatically. In OpenXML spreadsheet, when you copy some rows and insert copied rows into destination, there are many works to do. First, in the copied rows, maybe there are some merge cells, data validate &#8230; <a href="http://www.janabiz.com/openxml-copy-spreadsheet-rows/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://www.janabiz.com/openxml-copy-spreadsheet-rows/">OpenXML Spreadsheet, how to copy and insert specified rows</a> appeared first on <a href="http://www.janabiz.com">ジャナ・ビジネス・コンサルティング</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>We usually use OpenXML spreadsheet to create excel document and report. For some document and report, sometimes we hope copy and insert some rows or columns automatically. For example , we want to output a list data into excel worksheet whose element has 3 formatted rows including some merge cells etc. If list&#8217;s size is 10, we hope copy 3 formatted rows of first element 10 times and insert copied rows below the first element rows automatically. </p>
<p>In OpenXML spreadsheet, when you copy some rows and insert copied rows into destination, there are many works to do. First, in the copied rows, maybe there are some merge cells, data validate list ( pull down cells), formulas, drawings, charts. You must change the row&#8217;s index number to the inserted rows. Then the row&#8217;s index number for objects below in the destination must be changed. These objects include normal cells, merge cells, data validate list, formulas, drawings, charts etc.</p>
<p>The following is part of code to explain how to implement copy and insert. About the complete examples, please <a href="/dl?pcode=200002" alt="OpenXML spreadsheet | Excel solution | Excel Report | Excelソリューション">Download ExcelTDF Package</a> </p>
<div class="div-example">
<pre style="margin: 0; line-height: 125%">        <span style="color: #008000">/// &lt;summary&gt;                                                      </span>
        <span style="color: #008000">/// Copy the part of rows from srcRowFrom to srcRowTo between srcColFrom and srcColTo. </span>
        <span style="color: #008000">/// The row index, whose  column is between column srcColFrom and srcColTo, and whose</span>
        <span style="color: #008000">/// row is below the destRowFrom, will be changed after cloned cells added into worksheet.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;workbookPart&quot;&gt;&lt;see cref=&quot;WorkbookPart&quot;/&gt;&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;sheetIndex&quot;&gt;worksheet index&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;srcRowFrom&quot;&gt;source from row index&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;srcRowTo&quot;&gt;source to row index&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;destRowFrom&quot;&gt;destination from row index&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;copyTimes&quot;&gt;the times to be copied&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;srcColFrom&quot;&gt;limitation of column left&lt;/param&gt;</span>
        <span style="color: #008000">/// &lt;param name=&quot;srcColTo&quot;&gt;limitation of column right&lt;/param&gt;</span>
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> CopyRowRange(WorkbookPart workbookPart, <span style="color: #2b91af">int</span> sheetIndex,
            <span style="color: #2b91af">int</span> srcRowFrom, <span style="color: #2b91af">int</span> srcRowTo, <span style="color: #2b91af">int</span> destRowFrom, <span style="color: #2b91af">int</span> copyTimes, <span style="color: #2b91af">int</span> srcColFrom, <span style="color: #2b91af">int</span> srcColTo)
        {
            <span style="color: #008000">//only support copy down </span>
            <span style="color: #0000ff">if</span> (copyTimes &lt;= 0 || srcRowTo &lt; srcRowFrom || destRowFrom &lt; srcRowFrom) <span style="color: #0000ff">return</span>;
            <span style="color: #2b91af">int</span> destRowFromBase = destRowFrom;

            <span style="color: #008000">//Get the source sheet to be copied</span>
            WorksheetPart worksheetPart = GetWorksheetPart(workbookPart, sheetIndex);
            SheetData sheetData = worksheetPart.Worksheet.GetFirstChild&lt;SheetData&gt;();

            <span style="color: #008000">//get cells to be cloned according to the specified rows and columns</span>
            IList&lt;Cell&gt; cells = sheetData.Descendants&lt;Cell&gt;().Where(c =&gt;
                GetRowIndex(c.CellReference) &gt;= srcRowFrom &amp;&amp;
                GetRowIndex(c.CellReference) &lt;= srcRowTo &amp;&amp;
                GetCellColIndex(c.CellReference) &gt;= srcColFrom &amp;&amp;
                GetCellColIndex(c.CellReference) &lt;= srcColTo).ToList&lt;Cell&gt;();

            <span style="color: #008000">//no cells to be cloned</span>
            <span style="color: #0000ff">if</span> (cells.Count() == 0) <span style="color: #0000ff">return</span>;


            <span style="color: #008000">//after cloned, the index of rows from destRowFrom should be changed</span>
            <span style="color: #008000">//diff rows between srcColFrom and srcColTo</span>
            <span style="color: #2b91af">int</span> copiedRowCount = srcRowTo - srcRowFrom + 1;

            <span style="color: #008000">//move row index between srcColFrom and srcColTo that the row index greater or equal to </span>
            <span style="color: #008000">//destRowFrom</span>
            MoveRowIndex(workbookPart, sheetIndex, destRowFrom - 1, copiedRowCount * copyTimes, srcColFrom, srcColTo);

            <span style="color: #008000">//temporary array of changed row index</span>
            IList&lt;<span style="color: #2b91af">int</span>&gt; changeRowIndexs = <span style="color: #0000ff">new</span> List&lt;<span style="color: #2b91af">int</span>&gt;();

            <span style="color: #008000">//cloned cells, row index/cells</span>
            IDictionary&lt;<span style="color: #2b91af">int</span>, IList&lt;Cell&gt;&gt; clonedCells = <span style="color: #0000ff">null</span>;

            <span style="color: #008000">//formula cells in cloned cells</span>
            IList&lt;Cell&gt; formulaCells = <span style="color: #0000ff">new</span> List&lt;Cell&gt;();

            <span style="color: #008000">//cloned related rows for speed</span>
            IList&lt;Row&gt; cloneRelatedRows = <span style="color: #0000ff">new</span> List&lt;Row&gt;();

            <span style="color: #0000ff">for</span> (<span style="color: #2b91af">int</span> i = 0; i &lt; copyTimes; i++)
            {
                <span style="color: #008000">//next copy col index</span>
                destRowFrom = destRowFromBase + copiedRowCount * i;
                <span style="color: #008000">// changed column index</span>
                <span style="color: #2b91af">int</span> changedRows = destRowFrom - srcRowFrom;

                <span style="color: #008000">//add change column index to list</span>
                changeRowIndexs.Add(changedRows);
                <span style="color: #008000">//clear formula cells</span>
                formulaCells.Clear();

                <span style="color: #008000">//1: cloned cells, row index/cell list </span>
                clonedCells = <span style="color: #0000ff">new</span> Dictionary&lt;<span style="color: #2b91af">int</span>, IList&lt;Cell&gt;&gt;();

                <span style="color: #0000ff">foreach</span> (Cell cell <span style="color: #0000ff">in</span> cells)
                {
                    Cell newCell = (Cell)cell.CloneNode(<span style="color: #0000ff">true</span>);
                    <span style="color: #2b91af">int</span>[] indexs = GetCellIndex(cell.CellReference);
                    <span style="color: #008000">//change row index of cloned cell</span>
                    <span style="color: #2b91af">int</span> rowIndex = indexs[1] + changedRows;
                    newCell.CellReference = GetColumnName(cell.CellReference) + rowIndex.ToString();

                    IList&lt;Cell&gt; rowCells = <span style="color: #0000ff">null</span>;
                    <span style="color: #0000ff">if</span> (clonedCells.ContainsKey(rowIndex))
                        rowCells = clonedCells[rowIndex];
                    <span style="color: #0000ff">else</span>
                    {
                        rowCells = <span style="color: #0000ff">new</span> List&lt;Cell&gt;();
                        clonedCells.Add(rowIndex, rowCells);
                    }
                    rowCells.Add(newCell);

                    <span style="color: #008000">//if is formula cell</span>
                    <span style="color: #0000ff">if</span> (newCell.CellFormula != <span style="color: #0000ff">null</span> &amp;&amp; newCell.CellFormula.Text.Length &gt; 0)
                    {
                        formulaCells.Add(newCell);
                    }
                }

                <span style="color: #008000">//add cloned cell into row</span>
                <span style="color: #0000ff">foreach</span> (<span style="color: #2b91af">int</span> rowIndex <span style="color: #0000ff">in</span> clonedCells.Keys)
                {
                    Row row = sheetData.Elements&lt;Row&gt;().Where(r =&gt; r.RowIndex == rowIndex).FirstOrDefault();
                    <span style="color: #008000">//if no this row </span>
                    <span style="color: #0000ff">if</span> (row == <span style="color: #0000ff">null</span>)
                    {
                        row = <span style="color: #0000ff">new</span> Row() { RowIndex = (<span style="color: #2b91af">uint</span>)rowIndex };
                        <span style="color: #008000">//find insert position</span>
                        Row refRow = sheetData.Elements&lt;Row&gt;().Where(r =&gt; r.RowIndex &gt; rowIndex).OrderBy(r =&gt; r.RowIndex).FirstOrDefault();
                        <span style="color: #0000ff">if</span> (refRow == <span style="color: #0000ff">null</span>)
                            sheetData.AppendChild&lt;Row&gt;(row);
                        <span style="color: #0000ff">else</span>
                            sheetData.InsertBefore&lt;Row&gt;(row, refRow);
                    }
                    row.Append(clonedCells[rowIndex].ToArray());

                    <span style="color: #008000">//add into clone related rows</span>
                    cloneRelatedRows.Add(row);
                }

                <span style="color: #008000">//2: processing copied range&#39;s formula </span>
                ChangeFormulaRowNumber(formulaCells, changedRows);

                <span style="color: #008000">//3: copy drawings in range</span>
                CopyDrawingsInRange(worksheetPart, srcRowFrom, srcRowTo, srcColFrom, srcColTo, destRowFrom, -1);
            }

            <span style="color: #008000"></span>
            <span style="color: #0000ff">foreach</span> (Row row <span style="color: #0000ff">in</span> cloneRelatedRows)
            {
                <span style="color: #008000">// sort by column name</span>
                IList&lt;Cell&gt; cs = row.Elements&lt;Cell&gt;().OrderBy(c =&gt; GetCellColIndex(c.CellReference.Value)).ToList&lt;Cell&gt;();
                row.RemoveAllChildren();
                row.Append(cs.ToArray());
            }
            
            <span style="color: #008000">//2: process merge cell in cloned rows</span>
            MergeCells mcells = worksheetPart.Worksheet.GetFirstChild&lt;MergeCells&gt;();
            <span style="color: #0000ff">if</span> (mcells != <span style="color: #0000ff">null</span>)
            {
                IList&lt;MergeCell&gt; newMergeCells = <span style="color: #0000ff">new</span> List&lt;MergeCell&gt;();
                IEnumerable&lt;MergeCell&gt; clonedMergeCells = mcells.Elements&lt;MergeCell&gt;().
                    Where(m =&gt; MergeCellInRange(m, srcRowFrom, srcRowTo, srcColFrom, srcColTo)).ToList&lt;MergeCell&gt;();
                <span style="color: #0000ff">foreach</span> (MergeCell cmCell <span style="color: #0000ff">in</span> clonedMergeCells)
                {
                    <span style="color: #0000ff">foreach</span> (<span style="color: #2b91af">int</span> changedRows <span style="color: #0000ff">in</span> changeRowIndexs)
                    {
                        MergeCell newMergeCell = CreateChangedRowMergeCell(cmCell, changedRows);
                        newMergeCells.Add(newMergeCell);
                    }
                }
                <span style="color: #2b91af">uint</span> count = mcells.Count.Value;
                mcells.Count = <span style="color: #0000ff">new</span> UInt32Value(count + (<span style="color: #2b91af">uint</span>)newMergeCells.Count);
                mcells.Append(newMergeCells.ToArray());
            }

            <span style="color: #008000">//3: process datavalidate list</span>
            IDictionary&lt;<span style="color: #2b91af">string</span>, DataValidation&gt; validates = GetDataValidatesInRange(worksheetPart, srcRowFrom, srcRowTo, srcColFrom, srcColTo);
            <span style="color: #0000ff">foreach</span> (<span style="color: #2b91af">string</span> cellname <span style="color: #0000ff">in</span> validates.Keys)
            {
                <span style="color: #0000ff">foreach</span> (<span style="color: #2b91af">int</span> changedRows <span style="color: #0000ff">in</span> changeRowIndexs)
                {
                    AddDataValidateRefItemOfChangedRow(cellname, changedRows, validates[cellname]);
                }
            }
        }
</pre>
</div>
<p>The post <a href="http://www.janabiz.com/openxml-copy-spreadsheet-rows/">OpenXML Spreadsheet, how to copy and insert specified rows</a> appeared first on <a href="http://www.janabiz.com">ジャナ・ビジネス・コンサルティング</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.janabiz.com/openxml-copy-spreadsheet-rows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ExcelTDF, create excel report by metadata quickly</title>
		<link>http://www.janabiz.com/exceltdf-fast-create-excel-report-by-metadata/</link>
		<comments>http://www.janabiz.com/exceltdf-fast-create-excel-report-by-metadata/#comments</comments>
		<pubDate>Mon, 13 May 2013 09:37:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Spreadsheet]]></category>

		<guid isPermaLink="false">http://new.janabiz.com/?p=366</guid>
		<description><![CDATA[<p>ExcelTDF provides very simple way to create complicated excel report. ExcelTDF is able to process row range, column range, block range and complicated range which including some child ranges such as list, list clone range, list-in-list range etc. You can define these ranges by Metadata. Let us show some examples. Download Metadata examples FastExcelReport 1. Create a console application project: assume it is S:\project\FastExcelReport. 2. Set ExcelTDF configuration as following. 2.1. Add ExcelTDF repository configuration file Repository.config into your project. The content of Repository.config is shown as following &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34; ?&#62; &#60;objects xmlns=&#34;http://www.springframework.net&#34;&#62; &#60;object id=&#34;mydemo&#34; type=&#34;JanaBiz.OpenXml.Repository.FileSystemRepositoryManager, JanaBiz.OpenXml&#34;&#62; &#60;property name=&#34;RepositoryName&#34; value=&#34;mydemo&#34;/&#62; &#60;property name=&#34;RepositoryUri&#34; value=&#34;../Templates&#34;/&#62; &#60;/object&#62; &#60;/objects&#62; By the above configuration, &#8230; <a href="http://www.janabiz.com/exceltdf-fast-create-excel-report-by-metadata/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://www.janabiz.com/exceltdf-fast-create-excel-report-by-metadata/">ExcelTDF, create excel report by metadata quickly</a> appeared first on <a href="http://www.janabiz.com">ジャナ・ビジネス・コンサルティング</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>ExcelTDF provides very simple way to create complicated excel report. ExcelTDF is able to process row range, column range, block range and complicated range which including some child ranges such as list, list clone range, list-in-list range etc. You can define these ranges by Metadata. Let us show some examples.</p>
<p>Download Metadata examples <a href='/wp-content/uploads/FastExcelReport.zip'>FastExcelReport</a></p>
<p>1. Create a console application project: assume it is S:\project\FastExcelReport.</p>
<p>2. Set ExcelTDF configuration as following.</p>
<p>2.1. Add ExcelTDF repository configuration file <strong>Repository.config</strong> into your project. The content of Repository.config is shown as following</p>
<div class="div-example">
<pre style="margin: 0; line-height: 125%">&lt;?xml version=<span style="color: #a31515">&quot;1.0&quot;</span> encoding=<span style="color: #a31515">&quot;utf-8&quot;</span> ?&gt;
&lt;objects xmlns=<span style="color: #a31515">&quot;http://www.springframework.net&quot;</span>&gt;
  
  &lt;<span style="color: #2b91af">object</span> id=<span style="color: #a31515">&quot;mydemo&quot;</span> type=<span style="color: #a31515">&quot;JanaBiz.OpenXml.Repository.FileSystemRepositoryManager, JanaBiz.OpenXml&quot;</span>&gt;
    &lt;property name=<span style="color: #a31515">&quot;RepositoryName&quot;</span> <span style="color: #0000ff">value</span>=<span style="color: #a31515">&quot;mydemo&quot;</span>/&gt;
    &lt;property name=<span style="color: #a31515">&quot;RepositoryUri&quot;</span> <span style="color: #0000ff">value</span>=<span style="color: #a31515">&quot;../Templates&quot;</span>/&gt;
  &lt;/<span style="color: #2b91af">object</span>&gt;
&lt;/objects&gt;
</pre>
</div>
<p>By the above configuration, your template and template range configuration file are placed in the directory of ../Templates/mydemo (RepositoryName) which is related the executable directory bin.  The template file name *.xlsx and template range configuration file *.xml must have the same name, and this name is also their Template ID. ExcelTDF will search all templates and template range configuration files in root repository and subdirectories. <strong>When you use metadata, no template range configuration file is needed</strong></p>
<p>3. Design your template, here named MetadataTest.xslx, and save it into the specified path of repository configured above S:\project\FastExcelReport\Templates\mydemo\MetadataTest.xlsx </p>
<p><a href="/wp-content/uploads/metadatatest.png"><img src="/wp-content/uploads/metadatatest.png" alt="ExcelTDF .NET metadata | Excel report" title="ExcelTDF .NET metadata | Excel report" width="1280" height="994" class="aligncenter size-full wp-image-1265" /></a></p>
<p>4. Create your data model according to the template ranges.</p>
<p>4.1. Add reference assemblies<br />
&nbsp;&nbsp;&nbsp;&nbsp; . JanaBiz.OpenXml.dll<br />
&nbsp;&nbsp;&nbsp;&nbsp; . DocumentFormat.OpenXml.dll<br />
&nbsp;&nbsp;&nbsp;&nbsp; . log4net.dll<br />
&nbsp;&nbsp;&nbsp;&nbsp; . Spring.Core.dll</p>
<p>4.2. Create data model class as following</p>
<p><!-- HTML generated using hilite.me -->
<div class="div-example">
<pre style="margin: 0; line-height: 125%"><span style="color: #0000ff">using</span> System;
<span style="color: #0000ff">using</span> System.Collections.Generic;
<span style="color: #0000ff">using</span> System.Linq;
<span style="color: #0000ff">using</span> System.Text;
<span style="color: #0000ff">using</span> JanaBiz.OpenXml;

<span style="color: #008000">//define class for each range </span>
<span style="color: #0000ff">namespace</span> FastExcelReport
{
    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// Assume A-Range is root range</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    [ExcelRange(&quot;A-Range&quot;, &quot;A1&quot;, &quot;AF40&quot;, &quot;BlockRangeService&quot;)]
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">MetadataTestDataModel</span>
    {
        <span style="color: #0000ff">public</span> MetadataTestDataModel()
        {
            <span style="color: #0000ff">for</span> (<span style="color: #2b91af">int</span> i = 0; i &lt; 4; i++)
            {
                cRangeList.Add(<span style="color: #0000ff">new</span> CRange()
                {
                    Item1 = (i + 1) * 30
                });
            }
        }


        [Excel(&quot;AItem1&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">string</span> Item1 = <span style="color: #a31515">&quot;Item1 in range A&quot;</span>;

        [Excel(&quot;AItem3&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">string</span> Item3 = <span style="color: #a31515">&quot;Item3 in range A&quot;</span>;

        [ExcelRange(&quot;B-Range&quot;, &quot;G11&quot;, &quot;Q32&quot;, &quot;BlockRangeService&quot;)]
        <span style="color: #0000ff">public</span> BRange bRange = <span style="color: #0000ff">new</span> BRange();


        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// The range is defined by first element area</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        [ExcelRange(&quot;C-Range&quot;, &quot;T4&quot;, &quot;AE5&quot;, &quot;RowListRangeService&quot;, PageSize = 4)]
        <span style="color: #0000ff">public</span> IList&lt;CRange&gt; cRangeList = <span style="color: #0000ff">new</span> List&lt;CRange&gt;();            

        [ExcelRange(&quot;D-Range&quot;, &quot;B35&quot;, &quot;AF40&quot;, &quot;BlockRangeService&quot;)]
        <span style="color: #0000ff">public</span> DRange dRange = <span style="color: #0000ff">new</span> DRange();
    }

    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// The data model of B-Range</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">BRange</span>
    {
        [Excel(&quot;BItem1&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">string</span> Item1 = <span style="color: #a31515">&quot;Item1 in range B&quot;</span>;

        [Excel(&quot;BItem2&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">string</span> Item2 = <span style="color: #a31515">&quot;Item2 in range B&quot;</span>;

    }

    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// The data model of C-Range</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">CRange</span>
    {
        [Excel(&quot;CItem1&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">int</span> Item1 = 300;

        [Excel(&quot;CItem2&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">double</span> Item2;  <span style="color: #008000">//save the result of sum</span>

        [Excel(&quot;CItem3&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">double</span> Item3 = 12.5;

        [Excel(&quot;CItem4&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">string</span> Item4 = <span style="color: #a31515">&quot;Item4 in range C&quot;</span>;

        [Excel(&quot;CItem6&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">long</span> Item6 = 1290865;
    }


    <span style="color: #008000">/// &lt;summary&gt;</span>
    <span style="color: #008000">/// The data model of D-Range</span>
    <span style="color: #008000">/// &lt;/summary&gt;</span>
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">DRange</span>
    {
        <span style="color: #0000ff">private</span> <span style="color: #2b91af">string</span> item1 = <span style="color: #a31515">&quot;Item1 in range D&quot;</span>;


        [Excel(&quot;DItem1&quot;)]
        <span style="color: #0000ff">public</span> <span style="color: #2b91af">string</span> Item1
        {
            <span style="color: #0000ff">get</span> { <span style="color: #0000ff">return</span> item1; }
            <span style="color: #0000ff">set</span> { item1 = <span style="color: #0000ff">value</span>; }
        }
    }    
}
</pre>
</div>
<p><br/></p>
<p>5. Add following template processing code into your program. That is over</p>
<div class="div-example">
<pre style="margin: 0; line-height: 125%"><span style="color: #0000ff">using</span> System;
<span style="color: #0000ff">using</span> System.Collections.Generic;
<span style="color: #0000ff">using</span> System.Linq;
<span style="color: #0000ff">using</span> System.Text;
<span style="color: #0000ff">using</span> System.IO;
<span style="color: #0000ff">using</span> System.Reflection;

<span style="color: #0000ff">using</span> JanaBiz.OpenXml.Template;
<span style="color: #0000ff">using</span> JanaBiz.OpenXml.Handler;
<span style="color: #0000ff">using</span> JanaBiz.OpenXml.Data;
<span style="color: #0000ff">using</span> JanaBiz.OpenXml.Context;
<span style="color: #0000ff">using</span> JanaBiz.OpenXml.Repository;


<span style="color: #008000">//load configuration of repository</span>
<strong>[assembly: RegisterRepository(&quot;FastExcelReport.Repository.config&quot;)]</strong>

<span style="color: #0000ff">namespace</span> FastExcelReport
{
    <span style="color: #0000ff">class</span> <span style="color: #2b91af">Program</span>
    {
        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #2b91af">string</span>[] args)
        {

<span style="color: #008000">//            OpenXmlContext.RegisterRepository(&quot;FastExcelReport.Repository.config&quot;);</span>

            <span style="color: #008000">//create your handler </span>
            IOpenXmlHandler handler = <span style="color: #0000ff">new</span> OpenXmlHandler();

            <span style="color: #008000">//tell ExcelTDF which ITemplateService is used to </span>
            <span style="color: #008000">//get template file and template range configuration</span>
            handler.GetTemplateService&lt;LocalTemplateService&gt;();

            <span style="color: #008000">//set template id to identify which template is used</span>
            handler.TemplateId = <span style="color: #a31515">&quot;MetadataTest&quot;</span>;

            <span style="color: #008000">//tell ExcelTDF which IDataProviderManager and </span>
            <span style="color: #008000">//what data provider is used            </span>
            handler.DataProviderManager = <span style="color: #0000ff">new</span> DataModelProviderManager(
                <span style="color: #0000ff">new</span> MetadataTestDataModel());

            <span style="color: #008000">//parse your template </span>
           <strong> handler.ParseTemplate(<span style="color: #0000ff">false</span>);</strong>

            <span style="color: #008000">//parse your data </span>
            handler.ParseWorkbook(<span style="color: #0000ff">null</span>);

            <span style="color: #008000">//PLEASE REPLACE with your file stream to get result document</span>
            FileStream fs = <span style="color: #0000ff">new</span> FileStream(<span style="color: #a31515">@&quot;c:\temp\metadatatest-result.xlsx&quot;</span>, FileMode.Create);           

            <span style="color: #008000">//write parsed document into response stream</span>
            handler.WriteParsedDocument(fs);
            fs.Close();

            <span style="color: #008000">//release some resource</span>
            handler.Close();
        }
    }
}
</pre>
</div>
<p>
The line of </p>
<div class="div-example">
<pre style="margin: 0; line-height: 125%">[assembly: RegisterRepository(&quot;FastExcelReport.Repository.config&quot;)]
</pre>
</div>
<p>is used to load Repository.config file.</p>
<p>The result of pecessed template is show as following.</p>
<p><a href="/wp-content/uploads/metadatatest-result.png"><img src="/wp-content/uploads/metadatatest-result.png" alt="ExcelTDF .NET metadata | fast Excel report" title="ExcelTDF .NET metadata | fast Excel report-result" width="1280" height="994" class="aligncenter size-full wp-image-1266" /></a></p>
<p>The post <a href="http://www.janabiz.com/exceltdf-fast-create-excel-report-by-metadata/">ExcelTDF, create excel report by metadata quickly</a> appeared first on <a href="http://www.janabiz.com">ジャナ・ビジネス・コンサルティング</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.janabiz.com/exceltdf-fast-create-excel-report-by-metadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: www.janabiz.com @ 2026-05-02 03:58:58 by W3 Total Cache -->