.xlsx to .html folder hierarchy

Hi
Can I change hierarchy of folders when saving .xlsx to .html? I mean that it's creating index.html and folder index_files in root folder (and also some other files). But I need something like this:
root_folder
--- index.html
--- filelist.xml
--- tabstrip.htm
--- sheets
------ sheet001.htm
------ sheet002.htm
--- styles
------ stylesheet.css

Hi,


Thanks for your query.

I think it might not be possible to move specific files to specific custom folders by Aspose.Cells APIs. Even this is not possible by MS Excel either. You may confirm this by saving a spreadsheet to HTML file (Web Page) in MS Excel manually, you will notice MS Excel does generate the main HTML file and a folder in the format e.g xxxxx_files which contains individual .htm files for the sheets, a .css file, and other xml/html files, etc. Aspose.Cells follows MS Excel standards and specifications when rendering to HTML file.

Thank you.

Ok, thank you for rapid answer

Hi,


I think you may make use of Aspose.Cells APIs and some java.io classes to accomplish your task for your requirements. Please refer to the following sample code for your reference. The code is in .NET, so you may easily convert it to JAVA for your needs:
e.g.
Sample code:

static void TestFile()
{
string filePath = @“E:\Test\Files\test\aa”;

Workbook wb = new Workbook(filePath + “a.xlsx”);
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.Html);
saveOptions.IsFullPathLink = true;
saveOptions.StreamProvider = new ExportStreamProvider(filePath);
wb.Save(filePath + “out.html”, saveOptions);
}
public class ExportStreamProvider : IStreamProvider
{
private string outputDir;
public ExportStreamProvider(string dir)
{
outputDir = dir;
}
public void InitStream(StreamProviderOptions options)
{
string path = outputDir + Path.GetFileName(options.DefaultPath);
string fileName = Path.GetFileName(path);
string dir = Path.GetDirectoryName(path);
if (fileName.StartsWith(“sheet”))
{
path = dir + @"\sheets" + fileName;
}
else if (fileName.Equals(“stylesheet.css”))
{
path = dir + @"\styles" + fileName;
}
else if (fileName.Equals(“filelist.xml”) || fileName.Equals(“tabstrip.htm”))
{
path = path;
}
else
{
path = dir + @"\images" + fileName;
}
options.CustomPath = path;
Directory.CreateDirectory(Path.GetDirectoryName(path));
options.Stream = File.Create(path);
}

public void CloseStream(StreamProviderOptions options)
{
if (options != null && options.Stream != null)
{
options.Stream.Close();
}
}
}

Let us know if you still have any issue.

Thank you.