This project is read-only.

Anyone help to fix error (xls->html)

Mar 13 at 8:01 AM
Edited Mar 13 at 8:02 AM
Dear All,

Error on null return ($filepath), Please help to fix problem. Thanks.
$filepath = New-Object IO.FileStream "c:\ps\testa.xlsx", "Append", "Write", "Read"
$workbook.ExcelToHtmlUtils.LoadXls($filepath)

Powershell code as below:

[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.OOXML.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.OpenXml4Net.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.OpenXmlFormats.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\ICSharpCode.SharpZipLib.dll")

$workbook = new-object NPOI.XSSF.UserModel.XSSFWorkbook
$filepath = New-Object IO.FileStream "c:\ps\testa.xlsx", "Append", "Write", "Read"
$workbook.ExcelToHtmlUtils.LoadXls($filepath)

$ExcelToHtmlConverter = new-object NPOI.SS.Converter.ExcelToHtmlConverter;

$excelToHtmlConverter.OutputColumnHeaders = $false;
$excelToHtmlConverter.OutputHiddenColumns = $true;
$excelToHtmlConverter.OutputHiddenRows = $true;
$excelToHtmlConverter.OutputLeadingSpacesAsNonBreaking = $false;
$excelToHtmlConverter.OutputRowNumbers = $true;
$excelToHtmlConverter.UseDivsToSpan = $true;

$excelToHtmlConverter.ProcessWorkbook($workbook)

$excelToHtmlConverter.Document.Save([IO.Path]::ChangeExtension($filepath,"html"))

$filepath.Close()
$filepath.Dispose()