Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add support for .xlsm files

Marc Seitz424b8c3debc5
diff --git a/components/document-upload.tsx b/components/document-upload.tsx
index 6b05514a..1e2c064b 100644
--- a/components/document-upload.tsx
+++ b/components/document-upload.tsx
@@ -55,6 +55,7 @@ export default function DocumentUpload({
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
[], // ".xlsx"
+ "application/vnd.ms-excel.sheet.macroEnabled.12": [".xlsm"], // ".xlsm"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
"application/vnd.ms-powerpoint": [], // ".ppt"
@@ -181,7 +182,7 @@ export default function DocumentUpload({
? "Replace file?"
: isFreePlan && !isTrial
? `Only *.pdf, *.xls, *.xlsx, *.csv, *.ods, *.png, *.jpeg, *.jpg & ${maxSize} MB limit`
- : `Only *.pdf, *.pptx, *.docx, *.xlsx, *.xls, *.csv, *.ods, *.ppt, *.odp, *.doc, *.odt, *.dwg, *.dxf, *.png, *.jpg, *.jpeg & ${maxSize} MB limit`}
+ : `Only *.pdf, *.pptx, *.docx, *.xlsx, *.xls, *.xlsm, *.csv, *.ods, *.ppt, *.odp, *.doc, *.odt, *.dwg, *.dxf, *.png, *.jpg, *.jpeg & ${maxSize} MB limit`}
</p>
</div>
</div>
diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsx
index 9bd36176..4c63c372 100644
--- a/components/documents/add-document-modal.tsx
+++ b/components/documents/add-document-modal.tsx
@@ -102,6 +102,11 @@ export function AddDocumentModal({
contentType = `image/vnd.${currentFile.name.split(".").pop()}`;
}
+ if (currentFile.name.endsWith(".xlsm")) {
+ supportedFileType = "sheet";
+ contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";
+ }
+
if (!supportedFileType) {
setUploading(false);
toast.error(
diff --git a/components/upload-zone.tsx b/components/upload-zone.tsx
index f7d3bb9c..15e09b38 100644
--- a/components/upload-zone.tsx
+++ b/components/upload-zone.tsx
@@ -37,6 +37,7 @@ const allAcceptableDropZoneMimeTypes = {
"application/pdf": [], // ".pdf"
"application/vnd.ms-excel": [], // ".xls"
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx"
+ "application/vnd.ms-excel.sheet.macroEnabled.12": [".xlsm"], // ".xlsm"
"text/csv": [], // ".csv"
"application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": [], // ".docx"
@@ -247,6 +248,11 @@ export default function UploadZone({
contentType = `image/vnd.${uploadResult.fileName.split(".").pop()}`;
}
+ if (uploadResult.fileName.endsWith(".xlsm")) {
+ supportedFileType = "sheet";
+ contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";
+ }
+
const documentData: DocumentData = {
key: uploadResult.id,
supportedFileType: supportedFileType,
diff --git a/lib/constants.ts b/lib/constants.ts
index 8297c03f..69abc170 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -80,6 +80,7 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = [
"application/pdf", // .pdf
"application/vnd.ms-excel", // .xls
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // .xlsx
+ "application/vnd.ms-excel.sheet.macroEnabled.12", // .xlsm
"text/csv", // .csv
"application/vnd.oasis.opendocument.spreadsheet", // .ods
"application/vnd.ms-powerpoint", // .ppt
diff --git a/lib/files/put-file.ts b/lib/files/put-file.ts
index 999ea60d..0e953dcf 100644
--- a/lib/files/put-file.ts
+++ b/lib/files/put-file.ts
@@ -79,7 +79,8 @@ const putFileInS3 = async ({
if (
!SUPPORTED_DOCUMENT_MIME_TYPES.includes(file.type) &&
!file.name.endsWith(".dwg") &&
- !file.name.endsWith(".dxf")
+ !file.name.endsWith(".dxf") &&
+ !file.name.endsWith(".xlsm")
) {
throw new Error(
"Only PDF, Powerpoint, Word, and Excel, ZIP files are supported",
diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.ts
index c27357d7..f0484e0d 100644
--- a/lib/utils/get-content-type.ts
+++ b/lib/utils/get-content-type.ts
@@ -4,6 +4,7 @@ export function getSupportedContentType(contentType: string): string | null {
return "pdf";
case "application/vnd.ms-excel":
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
+ case "application/vnd.ms-excel.sheet.macroEnabled.12":
case "text/csv":
case "application/vnd.oasis.opendocument.spreadsheet":
return "sheet";
@@ -40,6 +41,8 @@ export function getExtensionFromContentType(
return "xls";
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
return "xlsx";
+ case "application/vnd.ms-excel.sheet.macroEnabled.12":
+ return "xlsm";
case "text/csv":
return "csv";
case "application/vnd.oasis.opendocument.spreadsheet":