I am using the GroupDocs Conversion Cloud API to convert a CSV file to HTML in Node.js. I have followed the code provided in the GroupDocs documentation, but I am not getting the correct HTML output from the CSV. Can somebody help me identify where the issue might be in my code.
const conversion_cloud = require("groupdocs-conversion-cloud");
let fileApi = conversion_cloud.FileApi.fromKeys(clientId, clientSecret);
let filecontent = "Name,Age,Email,Address John Doe,30,[email protected],123 Main StJane Smith,25,[email protected],456 Elm AveMichael Johnson,28,[email protected],789 Oak RdEmily Williams,32,[email protected],101 Pine Lane";
let uploaRequest = new conversion_cloud.UploadFileRequest('./spread.csv', filecontent);
await fileApi.uploadFile(uploaRequest).then(async (result, err) => {
if (err) {
console.log("upload- ", err);
return res.status(500).send(false);
} else {
console.log("document uploaded", result);
}
let loadOptions = new conversion_cloud.CsvLoadOptions();
loadOptions.separator = ",";
loadOptions.convertDateTimeData = true;
let settings = new conversion_cloud.ConvertSettings();
settings.filePath = './spread.csv';
settings.format = "html";
convertOptions = new conversion_cloud.HtmlConvertOptions();
convertOptions.fixedLayout = false;
convertOptions.usePdf = false;
result = await convertApi.convertDocument(new conversion_cloud.ConvertDocumentRequest(settings));
console.log('CSV file converted to HTML successfully.');
return res.send(data);
}) catch (error) {
console.error('Error converting CSV to HTML:', error);
}
Your reported issue is fixed in GroupDocs.Conversion Cloud 23.10. Please try the latest version of GroupDocs.Conversion Cloud SDK for Node.js.
Convert CSV to HTML in Node.js