static void TestFilePathProvider()
{
// Create subdirectory for second and third worksheets
Directory.CreateDirectory(dirPath + "OtherSheets");
// Load sample workbook from your directory
Workbook wb = new Workbook(dirPath + "Sample.xlsx");
// Save worksheets to separate html files
// Because of IFilePathProvider, hyperlinks will not be broken.
for (int i = 0; i < wb.Worksheets.Count; i++)
{
// Set the active worksheet to current value of variable i
wb.Worksheets.ActiveSheetIndex = i;
// Creat html save option
HtmlSaveOptions options = new HtmlSaveOptions();
options.ExportActiveWorksheetOnly = true;
// ExStart:hyperlinks
// If you will comment this line, then hyperlinks will be broken
options.FilePathProvider = new FilePathProvider();
// ExEnd:hyperlinks
// Sheet actual index which starts from 1 not from 0
int sheetIndex = i + 1;
string filePath = "";
// Save first sheet to same directory and second and third worksheets to subdirectory
if (i == 0)
{
filePath = dirPath + "Sheet1.html";
}
else
{
filePath = dirPath + "OtherSheets\\Sheet" + sheetIndex + "_out.html";
}
// Save the worksheet to html file
wb.Save(filePath, options);
}
}