Coder Social home page Coder Social logo

Comments (17)

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

Does it work with empty doc? If not can you attach empty for comparison that works?

from officeimo.

Goddfrey avatar Goddfrey commented on August 26, 2024

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.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

This needs testing:

Old, but maybe still there.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

So i'm pretty confident this is due to forward slash

image
image

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.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

I've created a PR:

But requires testing, and I am pretty sure this is not the best option to do it like that

from officeimo.

Rofliex avatar Rofliex commented on August 26, 2024

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 :)

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

You mean created by OfficeIMO? Before or after the PR?

from officeimo.

Rofliex avatar Rofliex commented on August 26, 2024

You mean created by OfficeIMO? Before or after the PR?

Im didnt test with your changes. Used only latest release from nuget.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

Can you test with the PR?

from officeimo.

Rofliex avatar Rofliex commented on August 26, 2024

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.

from officeimo.

Rofliex avatar Rofliex commented on August 26, 2024

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.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

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?

from officeimo.

Rofliex avatar Rofliex commented on August 26, 2024

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.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024

So in other words Create Word Document, add paragraph, add paragraph alignment and it stops opening in Word? Which version of word?

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 26, 2024
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.

from officeimo.

tmheath avatar tmheath commented on August 26, 2024

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.

from officeimo.

tmheath avatar tmheath commented on August 26, 2024

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.

from officeimo.

Related Issues (20)

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.