GithubHelp home page GithubHelp logo

cuft / openmcdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ironfede/openmcdf

0.0 0.0 0.0 20.96 MB

Microsoft Compound File .net component - pure C# - NET Standard 2.0

License: Mozilla Public License 2.0

Batchfile 0.01% C# 99.99%

openmcdf's Introduction

openmcdf

Structured Storage .net component - pure C#

OpenMCDF is a 100% .net / C# component that allows developers to manipulate Microsoft Compound Document Files (also known as OLE structured storage).

Compound file includes multiple streams of information (document summary, user data) in a single container.

This file format is used under the hood by a lot of applications: all the documents created by Microsoft Office until the 2007 product release are structured storage files. Windows thumbnails cache files (thumbs.db) are compound documents as well as .msg Outlook messages. Visual Studio .suo files (solution options) are compound files and a lot of audio/video editing tools save project file in a compound container.

OpenMcdf supports read/write operations on streams and storages and traversal of structures tree. It supports version 3 and 4 of the specifications, uses lazy loading wherever possible to reduce memory usage and offer an intuitive API to work with structured files.

It's very easy to create a new compound file

byte[] b = new byte[10000];

CompoundFile cf = new CompoundFile();
CFStream myStream = cf.RootStorage.AddStream("MyStream");

myStream.SetData(b);
cf.Save("MyCompoundFile.cfs");
cf.Close();

You can open an existing one, an excel workbook (.xls) and use its main data stream

//A xls file should have a Workbook stream
String filename = "report.xls";
CompoundFile cf = new CompoundFile(filename);
CFStream foundStream = cf.RootStorage.GetStream("Workbook");
byte[] temp = foundStream.GetData();
//do something with temp
cf.Close();

Adding storage and stream items is just as easy...

CompoundFile cf = new CompoundFile();
CFStorage st = cf.RootStorage.AddStorage("MyStorage");
CFStream sm = st.AddStream("MyStream");

...as removing them

cf.RootStorage.Delete("AStream"); // AStream item is assumed to exist.

Call commit() method when you need to persist changes to the underlying stream

cf.RootStorage.AddStream("MyStream").SetData(buffer);
cf.Commit();

If you need to compress a compound file, you can purge its unused space

CompoundFile.ShrinkCompoundFile("MultipleStorage_Deleted_Compress.cfs"); 

OLE Properties handling for DocumentSummaryInfo and SummaryInfo streams
is now available via extension methods (beta - api subjected to changes)

PropertySetStream mgr = ((CFStream)target).AsOLEProperties();
for (int i = 0; i < mgr.PropertySet0.NumProperties; i++)
{
  ITypedPropertyValue p = mgr.PropertySet0.Properties[i];
  ...

OpenMcdf runs happily on the Mono platform and supports now .NET Standard 2.0

openmcdf's People

Contributors

ironfede avatar michaelp avatar henning-krause avatar masc1989 avatar smcilveen avatar mitaliamazon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.