en un clic
open-xml-package
// Guide and examples for using OpenXML Package features in the open_xml package.
// Guide and examples for using OpenXML Package features in the open_xml package.
| name | open-xml-package |
| description | Guide and examples for using OpenXML Package features in the open_xml package. |
The open_xml package is a comprehensive Dart library for generating, parsing, and verifying Office Open XML (OOXML) documents (.docx, .xlsx, .pptx). It uses package:file extensively to abstract away the file system, ensuring compatibility across different platforms (e.g. mobile, desktop, web, or memory-based file systems).
All core document types in open_xml (WordDocument, Workbook, and Presentation) require a FileSystem instance from package:file to interact with files.
import 'package:file/local.dart';
import 'package:open_xml/open_xml.dart';
Future<void> main() async {
const fs = LocalFileSystem();
// Create Documents using fs
final doc = await WordDocument.create(fs);
final wb = await Workbook.create(fs);
final pres = await Presentation.create(fs);
}
For environments like tests or the web, you can use the memory file system:
import 'package:file/memory.dart';
import 'package:open_xml/open_xml.dart';
Future<void> main() async {
final fs = MemoryFileSystem();
// Creates files entirely in memory
final doc = await WordDocument.create(fs);
await doc.save(fs.file('in_memory.docx'));
}
The API allows you to open existing Office documents.
final existingDoc = await WordDocument.open(fs.file('path/to/existing.docx'));
The core of open_xml handles:
For detailed usage, refer to the document-specific guides:
Guide and examples for using OpenXML Docx features in the open_xml package.
Guide and examples for using OpenXML Pptx features in the open_xml package.
Guide and examples for using OpenXML Xlsx features in the open_xml package.