delphi TMS FlexCel 预览Excel
<h1 id="tms-flexcel-预览excel">TMS FlexCel 预览Excel</h1><h2 id="属性和方法">属性和方法</h2>
<h3 id="tflexcelimgexport">TFlexCelImgExport</h3>
<p>用于将Excel文件导出为图像的组件。它可以返回图像对象或特定文件格式的实际字节。 (如 gif、tiff 或 png)</p>
<p><strong>unit</strong></p>
<p>FlexCel.Render</p>
<h3 id="tflexcelimgexportcreate">TFlexCelImgExport.Create</h3>
<p>创建一个新的 <code>FlexCelImgExport</code> 并将其分配给 Excel 文件。</p>
<pre><code class="language-delphi">constructor Create(const aWorkbook: TExcelFile);
constructor Create(const aWorkbook: TExcelFile; const aAllowOverwritingFiles: Boolean);
</code></pre>
<p><strong>重载</strong></p>
<p><code>Create(TExcelFile,Boolean)</code></p>
<p>创建一个新的 <code>FlexCelImgExport</code> 并将其分配给 Excel 文件,将<code>AllowOverwritingFiles</code>设置为所需的值。</p>
<p><strong>参数</strong></p>
<p><em>aWorkbook</em>包含此组件将导出的数据的Excel 文件。</p>
<p><em>aAllowOverwritingFiles</em>当为<em>true</em>时,现有文件将被覆盖。</p>
<h3 id="tflexcelimgexportallvisiblesheets">TFlexCelImgExport.AllVisibleSheets</h3>
<p>如果为 <em>true</em>,则将打印工作簿上的所有可见工作表。</p>
<pre><code class="language-delphi">property AllVisibleSheets: Boolean
</code></pre>
<h3 id="tflexcelpreviewerdocument">TFlexCelPreviewer.Document</h3>
<p>要预览的文档。</p>
<pre><code class="language-delphi">property Document: TFlexCelImgExport
</code></pre>
<h3 id="tflexcelpreviewerinvalidatepreview">TFlexCelPreviewer.InvalidatePreview</h3>
<p>使预览无效并强制控件从文档中重新加载。 当控件是缩略图时,无法使其无效,这将在您使主视图无效时自动完成。</p>
<pre><code class="language-delphi">procedure InvalidatePreview;
</code></pre>
<h2 id="例子">例子</h2>
<h3 id="预览excel">预览Excel</h3>
<p>在窗体上放置TFlexCelPreviewer组件<em>FlexCelPreviewer1</em></p>
<pre><code class="language-delphi">procedure TForm1.Button6Click(Sender: TObject);
var
XLS: TXlsFile;
ImgExport: TFlexCelImgExport;
begin
//读取Excel文件
Xls := TXlsFile.Create('C:\Users\Administrator\Desktop\ceshi.xlsx');
//将Excel文件导出为图像
ImgExport := TFlexCelImgExport.Create(Xls, false);
//不显示隐藏Sheet
ImgExport.AllVisibleSheets := False;
//设置要预览的文档
FlexCelPreviewer1.Document := ImgExport;
//加载文档
FlexCelPreviewer1.InvalidatePreview;
end;
</code></pre><br><br>
来源:https://www.cnblogs.com/txgh/p/16445386.html
頁:
[1]