Closed Goddfrey closed 1 week ago
Does it work with empty doc? If not can you attach empty for comparison that works?
Sure. Although both Open Office and Libre Office are free if you want to run some tests of your own.
libre_office_empty.docx OfficeIMO_empty.docx
I created two empty docx files, one using Libre Office and another using this code:
using (WordDocument document = WordDocument.Create(path, true))
{
document.Save();
}
Open Office does open the one created with Libre Office, and does not open the one created with Office IMO.
This needs testing:
Old, but maybe still there.
So i'm pretty confident this is due to forward slash
There are plenty of issues around that:
I saw some project actively changing it:
OpenXMLSDK doesn't expose those paths directly from what I see.
I can see ClosedXML having similar issue:
I am not sure how to fix it. I'm open for fixes/suggestions as I can see it being useful, but don't have high hopes.
I see this code:
But after trying to apply it I get unreadable word. I guess i'm missing some details.
I've created a PR:
But requires testing, and I am pretty sure this is not the best option to do it like that
I have the same problem, but new documents created from a template (I use a copy in memory of a document that is on disk) cannot be opened in MS Word, but work correctly in LibreOffice and Google docs :)
You mean created by OfficeIMO? Before or after the PR?
You mean created by OfficeIMO? Before or after the PR?
Im didnt test with your changes. Used only latest release from nuget.
Can you test with the PR?
Can you test with the PR?
I checked your fix from PR. It doesn't work in my case :( I'll try to get the logs from Ms Word where the docx file parser got an exception, and maybe figure out what's wrong.
I found compatibility issues with the property Paragraph .ParagraphAlignment. If you override this property or set it for a new paragraph, it will cause errors in Ms Word and you will not be able to open a new document.
I found compatibility issues with the property Paragraph .ParagraphAlignment. If you override this property or set it for a new paragraph, it will cause errors in Ms Word and you will not be able to open a new document.
So under which conditions exactly your documents don't open? They don't open in MS Word? What is the code you're using - i'm a bit confused what doesn't work for you?
I found compatibility issues with the property Paragraph .ParagraphAlignment. If you override this property or set it for a new paragraph, it will cause errors in Ms Word and you will not be able to open a new document.
So under which conditions exactly your documents don't open? They don't open in MS Word? What is the code you're using - i'm a bit confused what doesn't work for you?
I apologize for flooding this issue. In general, if I add any paragraph to a document and define the ParagraphAlignment property using the library, the document stops opening. If I don’t touch the ParagraphAlignment property, then everything opens fine.
So in other words Create Word Document, add paragraph, add paragraph alignment and it stops opening in Word? Which version of word?
public static void Example_BasicWord(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with paragraph");
string filePath = System.IO.Path.Combine(folderPath, "BasicDocumentWithParagraphs.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
var paragraph = document.AddParagraph("Adding paragraph with some text");
paragraph.ParagraphAlignment = JustificationValues.Center;
//Console.WriteLine(SixLabors.ImageSharp.Color.Blue.ToHexColor());
//Console.WriteLine(SixLabors.ImageSharp.Color.Crimson.ToHexColor());
//Console.WriteLine(SixLabors.ImageSharp.Color.Aquamarine.ToHexColor());
//paragraph.Color = SixLabors.ImageSharp.Color.Red;
//paragraph = document.AddParagraph("Adding another paragraph with some more text");
//paragraph.Bold = true;
//paragraph = paragraph.AddText(" , but now we also decided to add more text to this paragraph using different style");
//paragraph.Underline = UnderlineValues.DashLong;
//paragraph = paragraph.AddText(" , and we still continue adding more text to existing paragraph.");
//paragraph.Color = SixLabors.ImageSharp.Color.CornflowerBlue;
document.Save(true);
}
}
I just did this and it worked. You need to be more specific.
I was using LibreOffice for this from home last year, it seemed to work fine. If it's something specific like how you mentioned the property, I can't say anything, the documents were simple at the time.
Just noticed this was about OpenOffice... It's a virtually dead project on life support for years, apparently it has a userbase but people really should not be using it, not sure if there's an issue with it being dead or not.
I'm getting "general input/output error" from Open Office. Here's the code I used to create a test document:
Libre Office opens the same file just fine and I can see the table created. And I don't have MS Word. test.docx
Unfortunately OpenOffice can only read .docx it apparently has no way to save a document as .docx so I cannot check what's missing by creating similar table by hand and then extracting and comparing the two.
I did create a similar simple table docx using LibreOffice, that OpenOffice can open, and I can see quite a few differences. Folder docProps does not exist in the one created by OfficeIMO. Folder word created by Libre Office has 2 subfolders (_rels, theme) and 4 files while the one created by OfficeIMO has same two subfolders and 8 files, and so on. Alas I dont know which of the differences matter and which do not.