Coder Social home page Coder Social logo

Comments (4)

PrzemyslawKlys avatar PrzemyslawKlys commented on July 23, 2024 1

PR was merged

      public static void Example_BasicWordWithDefaultStyleChange(string folderPath, bool openWord) {
            Console.WriteLine("[*] Creating standard document with different default style");
            string filePath = System.IO.Path.Combine(folderPath, "BasicWordWithDefaultStyleChange.docx");
            using (WordDocument document = WordDocument.Create(filePath)) {
                document.Settings.FontSize = 30;
                document.Settings.FontFamily = "Calibri Light";
                document.Settings.Language = "pl-PL";

                var paragraph1 = document.AddParagraph("To jest po polsku");

                var paragraph2 = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER");
                paragraph2.FontSize = 15;
                paragraph2.FontFamily = "Courier New";

                document.Save(openWord);
            }
        }

Should be available in next version

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on July 23, 2024

It's not exposed now, but I would suggest doing this differently. Just work without setting font family and then once everything is done just loop thru all paragraphs

foreach (var paragraph in document.Paragraphs) {
    paragraph.SetFontFamily(...).SetFontSize(10)
}

You will fix this in 3 lines. I'll keep this open, as it should be possible to define default font/style.

from officeimo.

eliseudev avatar eliseudev commented on July 23, 2024

Não está exposto agora, mas eu sugeriria fazer isso de forma diferente. Basta trabalhar sem definir a família font e, em seguida, uma vez que tudo é feito apenas loop th através de todos os parágrafos

foreach (var paragraph in document.Paragraphs) {
    paragraph.SetFontFamily(...).SetFontSize(10)
}

Você vai consertar isso em 3 linhas. Vou manter isso aberto, pois deve ser possível definir fonte padrão/style.

Thanks, I thought I had a generic method, but so too solves my problem.

from officeimo.

PrzemyslawKlys avatar PrzemyslawKlys commented on July 23, 2024

I will add native way to do it in next release:

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.