const puppeteerVar = require(‘puppeteer’)
var xlsx = require(“xlsx”)
var fs = require(‘fs’)
describe(‘Title : Convert Excel To PDF’,()=(greather than){
it(‘Test Case : Convert Excel To PDF’, async function(){
const browser = await puppeteerVar.launch({headless:true, slowMo:500})
const page = await browser.newPage();
var dataPathExcelToRead = “Sample.xlsx”
var wb = xlsx.readFile(dataPathExcelToRead)
var sheetName = wb.SheetNames[0]
var sheetValue = wb.Sheets[sheetName]
var htmlData = xlsx.utils.sheet_to_html(sheetValue)
fs.writeFile(‘excelToHtml.html’,htmlData,function(err){
console.log(“Data is successfully converted”)
})
await page.waitForTimeout(3000)
await page.goto(‘C:/Users/Azhar/Desktop/Puppeteer%20Project/excelToHtml.html’,{“waitUntil”:”networkidle2″}).catch(function(){
console.log(“Error while loading the file”)
})
await page.waitForTimeout(3000)
await page.pdf({path:’./ExcelToPDF.pdf’,format:’A4′,printBackground:true});
await browser.close()
})
})
Next Steps :
———————————————————————————————————————————————————
———————————————————————————————————————————————————
Must Watch Playlists
► 1. Javascript –
► 2. Puppetter –
► 3. Cypress –
► 4. Tech works –
► 5. Vbscript Basics To Advanced –
► 6. Jmeter –
► 7. Excel –
► 8. Appium –
———————————————————————————————————————————————————
———————————————————————————————————————————————————
#excel2pdf
#convertexceltopdf
#excelfiletopdffile…(read more)
Convert Word 2 PDF: Word to PDF Converter
Convert PowerPoint 2 PDF: PPT to PDF Converter
Convert Excel 2 PDF: Excel to PDF Converter
Convert an Image 2 PDF: Image to PDF Converter
Convert HTML 2 PDF: HTML to PDF Converter
More Tools: PDF Converter
what if we have charts as well inside excel sheet
@Thanks for this. What about the formatting and styles.? Is it possible to create html with all the formatting? Also how to embedd multiple sheet html into one html page?
Does this code includes also charts and other vectoral or raster images into PDF? This is very important nuance.
Nice one
ReferenceError: describe is not defined
Nice one bro
Js suchst…i need 2 minutes in vba!