The library uses the ResolveDocumentType method to map file extensions to OnlyOffice editor types:
OnlyOfficeEditor.ascx.cs:411-427
private static string ResolveDocumentType(string fileType){ switch ((fileType ?? "").ToLowerInvariant()) { case "xls": case "xlsx": case "ods": case "csv": return "cell"; case "ppt": case "pptx": case "odp": return "slide"; default: return "word"; }}
How it works
Extracts file extension from DocumentName
Converts extension to lowercase for case-insensitive matching
Returns the appropriate OnlyOffice document type identifier:
cell for spreadsheets
slide for presentations
word for text documents (default)
Includes the type in the editor configuration JSON
// Edit a Word documentdocEditor.SetDocumentFromFile("report.docx");docEditor.Mode = "edit";// Edit an Excel spreadsheetdocEditor.SetDocumentFromFile("budget.xlsx");// Edit a PowerPoint presentationdocEditor.SetDocumentFromFile("slides.pptx");
The library supports converting documents to PDF regardless of the source format:
OnlyOfficeEditor.ascx.cs:163-207
private string ConvertDocumentSourceToPdfUrl(string sourceUrl, string sourceName, string sourceKey, int maxAttempts, int delayMs){ // Extract extension for conversion service var sourceExt = Path.GetExtension(sourceName)?.TrimStart('.').ToLowerInvariant(); if (string.IsNullOrWhiteSpace(sourceExt)) throw new InvalidOperationException("No fue posible determinar el tipo del documento."); var convertServiceUrl = ResolveConvertServiceUrl(); var serializer = new JavaScriptSerializer(); var requestPayload = new Dictionary<string, object> { ["async"] = false, ["filetype"] = sourceExt, // Source format ["outputtype"] = "pdf", // Target format ["url"] = sourceUrl, ["title"] = Path.GetFileName(sourceName), ["key"] = sourceKey }; // ... JWT signing and API call}
OnlyOffice attempts to open the file with the word processor
// Without extension - defaults to word processordocEditor.DocumentName = "MyDocument"; // No extensiondocEditor.DocumentUrl = "https://example.com/download/file123";
Always include file extensions in DocumentName for proper editor selection:
// GooddocEditor.SetDocumentFromBytes(data, "report.xlsx");// Bad - may open with wrong editordocEditor.SetDocumentFromBytes(data, "report");