creating docx file
creating docx file
- Subject: creating docx file
- From: Philip White <email@hidden>
- Date: Mon, 20 Sep 2010 14:57:22 -0500
Hello,
I've tried using the following code to save an attributed string as a docx file.
//the attributed string is 'contents'
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: NSOfficeOpenXMLTextDocumentType, NSDocumentTypeDocumentAttribute, nil];
NSRange range = {0,[contents length]};
NSError *error=nil;
NSFileWrapper *wrapper = [contents fileWrapperFromRange: range documentAttributes: attributes error: &error];
[wrapper writeToFile:[path stringByExpandingTildeInPath] atomically:YES updateFilenames:NO];
What I end up with is what appears to be an unzipped docx file (my understanding is that docx files are zipped archives), i.e a folder full of various resource files. I then try zipping it and changing the extension to docx but I don't seem to end up with a valid docx file, or at least not something that Pages 2008 can open. Maybe that version of Pages can't open that format anyway, but still that code clearly isn't creating what I would call a docx file. Any thoughts?
Thanks,
Philip
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden