# Wijmo_Grid_Xlsx.Flexgridxlsxconverter

## Content

<div class="content__tsd">
						<div style="display:flex;justify-content:space-between;align-items:center">
							<h1>
								FlexGridXlsxConverter Class
							</h1>
						</div>
						<section class="tsd-comment">
							<div class="tsd-comment">
								<div class="lead">
									<p>This class provides static <b>load</b> and <b>save</b> methods for loading
									and saving <a href="wijmo_grid.flexgrid.html">FlexGrid</a> controls from and to Excel xlsx files.</p>
								</div>
								<p>The example below shows how you can use the <a href="wijmo_grid_xlsx.flexgridxlsxconverter.html">FlexGridXlsxConverter</a> to
								export the content of a <a href="wijmo_grid.flexgrid.html">FlexGrid</a> control to XLSX:</p>
								<p><a href="/wijmo/demos/Grid/ImportExportPrint/Excel/Async/purejs" target="_blank">Example</a></p>
							</div>
						</section>
						<section class="tsd-hierarchy">
							<h3>Heirarchy</h3>
							<ul class="tsd-hierarchy">
								<li>
									<span class="target">FlexGridXlsxConverter</span>
								</li>
							</ul>
						</section>
						<section class="tsd-index-group">
							<section class="tsd-index-panel">
								<div class="tsd-index-content">
									<section class="tsd-index-section ">
										<div class="title">
											<div class="gc_api_tree-item_icon_img_wrapper">
												<div class="gc_api_tree-item_icon_img" data-expand="true">
												</div>
											</div>
											<h3>
												Methods
											</h3>
										</div>
										<ul class="tsd-index-list">
											<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="wijmo_grid_xlsx.flexgridxlsxconverter.html#cancelasync" class="tsd-kind-icon">cancel<wbr>Async</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="wijmo_grid_xlsx.flexgridxlsxconverter.html#load" class="tsd-kind-icon">load</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="wijmo_grid_xlsx.flexgridxlsxconverter.html#loadasync" class="tsd-kind-icon">load<wbr>Async</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="wijmo_grid_xlsx.flexgridxlsxconverter.html#save" class="tsd-kind-icon">save</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="wijmo_grid_xlsx.flexgridxlsxconverter.html#saveasync" class="tsd-kind-icon">save<wbr>Async</a></li>
										</ul>
									</section>
								</div>
							</section>
						</section>
						<section class="tsd-panel-group tsd-member-group ">
							<h2>Methods</h2>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
								<a name="cancelasync" class="tsd-anchor"></a>
								<h3><span class="tsd-flag ts-flagStatic">Static</span> cancelAsync</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
									<li class="tsd-signature tsd-kind-icon">cancel<wbr>Async<span class="tsd-signature-symbol">(</span>done<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Cancels the task started by the <a href="wijmo_grid_xlsx.flexgridxlsxconverter.html#saveasync">FlexGridXlsxConverter.saveAsync</a> method.</p>
											</div>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> done: <span class="tsd-signature-type">Object</span></h5>
												<div class="tsd-comment">
													<p>Callback invoked when the method finishes executing.</p>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
								<a name="load" class="tsd-anchor"></a>
								<h3><span class="tsd-flag ts-flagStatic">Static</span> load</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
									<li class="tsd-signature tsd-kind-icon">load<span class="tsd-signature-symbol">(</span>grid<span class="tsd-signature-symbol">: </span><a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a>, workbook<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Blob</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">mXlsx.Workbook</span>, options<span class="tsd-signature-symbol">?: </span><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Loads a <a href="wijmo_xlsx.workbook.html">Workbook</a> instance or a Blob object containing xlsx
													file content to the <a href="wijmo_grid.flexgrid.html">FlexGrid</a> instance.
												This method works with JSZip 2.5.</p>
											</div>
											<p>For example:</p>
											<pre>// This sample opens an xlsx file chosen through Open File
// dialog and fills FlexGrid with the content of the first
// sheet.
&nbsp;
// HTML
&lt;input type="file"
    id="importFile"
    accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
/&gt;
&lt;div id="flexHost"&gt;&lt;/&gt;
&nbsp;
// JavaScript
var flexGrid = new wijmo.grid.FlexGrid("#flexHost"),
    importFile = document.getElementById('importFile');
&nbsp;
importFile.addEventListener('change', function () {
    loadWorkbook();
});
&nbsp;
function loadWorkbook() {
    var reader,
        file = importFile.files[0];
    if (file) {
        reader = new FileReader();
        reader.onload = function (e) {
            wijmo.grid.xlsx.FlexGridXlsxConverter.load(flexGrid, reader.result,
                { includeColumnHeaders: true });
        };
        reader.readAsArrayBuffer(file);
    }
}</pre>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5>grid: <a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a></h5>
												<div class="tsd-comment">
													<p><a href="wijmo_grid.flexgrid.html">FlexGrid</a> that loads the <a href="wijmo_xlsx.workbook.html">Workbook</a> object.</p>
												</div>
											</li>
											<li>
												<h5>workbook: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Blob</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">mXlsx.Workbook</span></h5>
												<div class="tsd-comment">
													<p>A <a href="wijmo_xlsx.workbook.html">Workbook</a>, Blob, base-64 string, or ArrayBuffer
													containing the xlsx file content.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a></h5>
												<div class="tsd-comment">
													<p><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html">IFlexGridXlsxOptions</a> object specifying the load options.</p>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
								<a name="loadasync" class="tsd-anchor"></a>
								<h3><span class="tsd-flag ts-flagStatic">Static</span> loadAsync</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
									<li class="tsd-signature tsd-kind-icon">load<wbr>Async<span class="tsd-signature-symbol">(</span>grid<span class="tsd-signature-symbol">: </span><a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a>, workbook<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Blob</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">mXlsx.Workbook</span>, options<span class="tsd-signature-symbol">?: </span><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a>, onLoaded<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Object</span>, onError<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Asynchronously loads a <a href="wijmo_xlsx.workbook.html">Workbook</a> or a Blob representing an xlsx file
												into a <a href="wijmo_grid.flexgrid.html">FlexGrid</a>.</p>
											</div>
											<p>This method requires JSZip 3.0.</p>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5>grid: <a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a></h5>
												<div class="tsd-comment">
													<p><a href="wijmo_grid.flexgrid.html">FlexGrid</a> that loads the <a href="wijmo_xlsx.workbook.html">Workbook</a> object.</p>
												</div>
											</li>
											<li>
												<h5>workbook: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Blob</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">mXlsx.Workbook</span></h5>
												<div class="tsd-comment">
													<p><a href="wijmo_xlsx.workbook.html">Workbook</a>, Blob, base-64 string, or ArrayBuffer
													representing the xlsx file content.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a></h5>
												<div class="tsd-comment">
													<p><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html">IFlexGridXlsxOptions</a> object specifying the load options.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> onLoaded: <span class="tsd-signature-type">Object</span></h5>
												<div class="tsd-comment">
													<p>Callback invoked when the method finishes executing.
														The callback provides access to the workbook that was loaded
													(passed as a parameter to the callback).</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> onError: <span class="tsd-signature-type">Object</span></h5>
												<div class="tsd-comment">
													<p>Callback invoked when there are errors saving the file.
													The error is passed as a parameter to the callback.</p>
													<p>For example:</p>
													<pre>wijmo.grid.xlsx.FlexGridXlsxConverter.loadAsync(grid, blob, null, function (workbook) {
     // user can access the loaded workbook instance in this callback.
     var app = worksheet.application ;
     ...
}, function (reason) {
     // User can catch the failure reason in this callback.
     console.log('The reason of save failure is ' + reason);
});
</pre>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
								<a name="save" class="tsd-anchor"></a>
								<h3><span class="tsd-flag ts-flagStatic">Static</span> save</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
									<li class="tsd-signature tsd-kind-icon">save<span class="tsd-signature-symbol">(</span>grid<span class="tsd-signature-symbol">: </span><a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a>, options<span class="tsd-signature-symbol">?: </span><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a>, fileName<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, batchSize<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">mXlsx.Workbook</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Save the <a href="wijmo_grid.flexgrid.html">FlexGrid</a> instance to the <a href="wijmo_xlsx.workbook.html">Workbook</a> instance.
												This method works with JSZip 2.5.</p>
											</div>
											<p>For example:</p>
											<pre>// This sample exports FlexGrid content to an xlsx file.
// click.
&nbsp;
// HTML
&lt;button
    onclick="saveXlsx('FlexGrid.xlsx')"&gt;
    Save
&lt;/button&gt;
&nbsp;
// JavaScript
function saveXlsx(fileName) {
    // Save the flexGrid to xlsx file.
    wijmo.grid.xlsx.FlexGridXlsxConverter.save(flexGrid,
            { includeColumnHeaders: true }, fileName);
}</pre>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5>grid: <a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a></h5>
												<div class="tsd-comment">
													<p>FlexGrid that will be saved.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a></h5>
												<div class="tsd-comment">
													<p><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html">IFlexGridXlsxOptions</a> object specifying the save options.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> fileName: <span class="tsd-signature-type">string</span></h5>
												<div class="tsd-comment">
													<p>Name of the file that will be generated.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> batchSize: <span class="tsd-signature-type">number</span></h5>
												<div class="tsd-comment">
													<p>Batching is done while saving grid rows with excel, this parameter allows customize number of rows per batch.</p>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">mXlsx.Workbook</span></h4>
										<p>A <a href="wijmo_xlsx.workbook.html">Workbook</a> object that can be used to customize the workbook
										before saving it (with the Workbook.save method).</p>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
								<a name="saveasync" class="tsd-anchor"></a>
								<h3><span class="tsd-flag ts-flagStatic">Static</span> saveAsync</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
									<li class="tsd-signature tsd-kind-icon">save<wbr>Async<span class="tsd-signature-symbol">(</span>grid<span class="tsd-signature-symbol">: </span><a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a>, options<span class="tsd-signature-symbol">?: </span><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a>, fileName<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, onSaved<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Object</span>, onError<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Object</span>, onProgress<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Object</span>, asyncWorkbook<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span>, batchSize<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">mXlsx.Workbook</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Asynchronously saves the content of a <a href="wijmo_grid.flexgrid.html">FlexGrid</a> to a file.</p>
											</div>
											<p>This method requires JSZip 3.0.</p>
											<p>The return value depends on the {@link asyncWorkbook} parameter. If it is false (default) then the
												method returns the <a href="wijmo_xlsx.workbook.html">Workbook</a> instance. If it is true then the method returns a null value
											and the <a href="wijmo_xlsx.workbook.html">Workbook</a> instance should be obtained in the {@link onSaved} callback.</p>
											<p>If {@link asyncWorkbook} parameter is true then, once started, the task will be automatically
											restarted when changes in the grid are detected.</p>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5>grid: <a href="wijmo_grid.flexgrid.html" class="tsd-signature-type">FlexGrid</a></h5>
												<div class="tsd-comment">
													<p>FlexGrid that will be saved.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html" class="tsd-signature-type">IFlexGridXlsxOptions</a></h5>
												<div class="tsd-comment">
													<p><a href="../interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html">IFlexGridXlsxOptions</a> object specifying the save options.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> fileName: <span class="tsd-signature-type">string</span></h5>
												<div class="tsd-comment">
													<p>Name of the file that will be generated.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> onSaved: <span class="tsd-signature-type">Object</span></h5>
												<div class="tsd-comment">
													<p>Callback invoked when the method finishes executing.
														The callback provides access to the content of the saved workbook
													(encoded as a base-64 string and passed as a parameter to the callback).</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> onError: <span class="tsd-signature-type">Object</span></h5>
												<div class="tsd-comment">
													<p>Callback invoked when there are errors saving the file.
													The error is passed as a parameter to the callback.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> onProgress: <span class="tsd-signature-type">Object</span></h5>
												<div class="tsd-comment">
													<p>Callback function that gives feedback about the progress of a task.
														The function accepts a single argument, the current progress as a number between 0 and 100.
													Can be used only if the {@link asyncWorkbook} parameter is set to true.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> asyncWorkbook: <span class="tsd-signature-type">boolean</span></h5>
												<div class="tsd-comment">
													<p>Indicates whether Workbook genaration should be performed asynchronously or not.
													The default value is false.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> batchSize: <span class="tsd-signature-type">number</span></h5>
												<div class="tsd-comment">
													<p>Batching is done while saving grid rows with excel, this parameter allows customize number of rows per batch.</p>
													<p>For example:</p>
													<pre>wijmo.grid.xlsx.FlexGridXlsxConverter.saveAsync(flexGrid,
    { includeColumnHeaders: true }, // options
    'FlexGrid.xlsx', // filename
    function (base64) { // onSaved
        // User can access the base64 string in this callback.
        document.getElementByID('export').href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;' + 'base64,' + base64;
    },
    function (reason) { // onError
        // User can catch the failure reason in this callback.
        console.log('The reason of save failure is ' + reason);
    }
 );</pre>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">mXlsx.Workbook</span></h4>
									</li>
								</ul>
							</section>
						</section>
					</div>