As of February 2023 'Convert Drive Files' is now available as a Google Workspace Marketplace Add-on.
The following Google Apps Script is designed to iterate through a Google Drive folder of Microsoft Excel files and convert them all to individual Google Sheet files. It does not technically check a file is Excel only (eg you may have a Word document in there), but it is recommended to only try from Excel to Google Sheets otherwise the data may be unreadable.
Bulk convert Excel files to Google Sheets |
The Code
Make sure you have followed the instructions to enable the Drive API Service if you are writing this from scratch.
The little bit of code to focus on here is getting the Microsoft Excel file and creating a resource to turn it into a Google Sheet:
// convert Excel file into Google Sheet
var blob = file.getBlob();
var resource = {
title: fileName,
mimeType: MimeType.GOOGLE_SHEETS,
parents: [{ id: destinationFolderID }],
};
var newSheetID = Drive.Files.insert(resource, blob).id;
Download
Bulk convert Excel files to Google Sheet files download (please use 'Overview' > 'Make a copy' for your own version).
As of February 2023 'Convert Drive Files' is now available as a Google Workspace Marketplace Add-on.
Thanks, worked perfect first time for me. Much appreciate the help.
ReplyDelete