EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
279 stars 49 forks source link

Row heights/paragraph heights questions #107

Closed geraluca closed 1 year ago

geraluca commented 1 year ago

With any unit of measurement PCT or others imposed the height of the lines does not work, to say they can be expanded but under a certain extent you do not go down, wanting to put three lines of text one under the other (as is done for The header of a letter) cannot (without the table) reduce the space between the lines? Thank you

PrzemyslawKlys commented 1 year ago

I've a hard time understanding what you exactly mean. Please provide some example, please provide more details.

geraluca commented 1 year ago

This is my code (in Vb.net Basic) to set my table :

Dim T0 As WordTable = docux.AddTable(6, 2, WordTableStyle.TableNormal)

T0.WidthType = TableWidthUnitValues.Pct

T0.Width = 5000

T0.ColumnWidth = New List(Of Integer)() From {100, 100}

T0.RowHeight = New List(Of Integer)() From {1000, 200, 200, 200, 200, 200}

Ns. Rif. N° : 1968-MD2233

Data : 09/02/2023

Cliente :

Referente :

A.B.C.D. S.R.L.

Sig. Menegazzi

Via De Amicis, 81

Tel. 0114035070

Collegno

Cellulare 3389677060

TO 10093

@. @.>

This is the result, if imposed a line with greater height it is designed as I want it.

If the code changes to decrease the height of the first line in this way:

T0.RowHeight = New List(Of Integer)() From {100, 200, 200, 200, 200, 200}

The result is this:

Ns. Rif. N° : 1968-MD2233

Data : 09/02/2023

Cliente :

Referente :

A.B.C.D. S.R.L.

Sig. Menegazzi

Via De Amicis, 81

Tel. 0114035070

Collegno

Cellulare 3389677060

TO 10093

@. @.>

What I would like to get, is the possibility of putting a set of data on the document (for example customer address) with the lines one under the other in a precise position of folgio with little space between one line and the other, as in the Example that follows:

Da: Przemysław Kłys @.> Inviato: venerdì 10 febbraio 2023 09:42 A: EvotecIT/OfficeIMO @.> Cc: geraluca @.>; Author @.> Oggetto: Re: [EvotecIT/OfficeIMO] wordTable.RowHeight = new List() { 1000, 300, 500, 200 }; (Issue #107)

I've a hard time understanding what you exactly mean. Please provide some example, please provide more details.

— Reply to this email directly, view it on GitHub https://github.com/EvotecIT/OfficeIMO/issues/107#issuecomment-1425423459 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AICVVJEY3BSUHWKG4SSZ763WWX5MPANCNFSM6AAAAAAUXQPSFU . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AICVVJCWR6SOL3FOALHLJFTWWX5MPA5CNFSM6AAAAAAUXQPSFWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSU6Y6GG.gif Message ID: @. @.> >

PrzemyslawKlys commented 1 year ago

Please don't use emails to reply to GitHub issues, please put some effort into providing working example. Please show what you are getting in a way where I can asses what I am actually looking at. Please use code blocks.

geraluca commented 1 year ago

This is my code (in Vb.net Basic) to set my table :


Dim T0 As WordTable = docux.AddTable(6, 2, WordTableStyle.TableNormal)

T0.WidthType = TableWidthUnitValues.Pct

T0.Width = 5000

T0.ColumnWidth = New List(Of Integer)() From {100, 100}

T0.RowHeight = New List(Of Integer)() From {1000, 200, 200, 200, 200, 200}



Ns. Rif. N° : 1968-MD2233 | Data : 09/02/2023 -- | -- Cliente : | Referente : A.B.C.D. S.R.L. | Sig. Menegazzi Via De Amicis, 81 | Tel. 0114035070 Collegno | Cellulare 3389677060 TO 10093 | abcd@abcdsrl.it


What I would like to get, is the possibility of putting a set of data on the document (for example customer address) with the lines one under the other in a precise position of folgio with little space between one line and the other, as in the Example that follows:



geraluca commented 1 year ago

Ultimately, is there a way to write the text in a precise position? Thank you.

PrzemyslawKlys commented 1 year ago

I guess you;re looking for something like this:

image

public static void Example_AdvancedWord2(string folderPath, bool openWord) {
    Console.WriteLine("[*] Creating advanced document");
    string filePath = System.IO.Path.Combine(folderPath, "AdvancedDocument2.docx");
    using (WordDocument document = WordDocument.Create(filePath)) {
        var table = document.AddTable(1, 3);
        table.Alignment = TableRowAlignmentValues.Right;
        table.Width = 5000;
        table.WidthType = TableWidthUnitValues.Pct;
        table.ColumnWidth = new List<int>() { 1500, 2000, 1500 };

        // add on the left
        table.Rows[0].Cells[0].Paragraphs[0].Text = "To: ";
        table.Rows[0].Cells[0].Paragraphs[0].LineSpacingAfter = 0;
        table.Rows[0].Cells[0].Paragraphs[0].LineSpacingBefore = 0;

        table.Rows[0].Cells[0].Paragraphs[0].AddParagraph().AddText("Customer Company");
        table.Rows[0].Cells[0].Paragraphs[1].LineSpacingAfter = 0;
        table.Rows[0].Cells[0].Paragraphs[1].LineSpacingBefore = 0;

        table.Rows[0].Cells[0].Paragraphs[1].AddParagraph().AddText("40-308, Mikołów");
        table.Rows[0].Cells[0].Paragraphs[2].LineSpacingAfter = 0;
        table.Rows[0].Cells[0].Paragraphs[2].LineSpacingBefore = 0;

        table.Rows[0].Cells[0].Paragraphs[2].AddParagraph().AddText("Poland");
        table.Rows[0].Cells[0].Paragraphs[3].LineSpacingAfter = 0;
        table.Rows[0].Cells[0].Paragraphs[3].LineSpacingBefore = 0;

        // add on the right
        table.Rows[0].Cells[2].Paragraphs[0].Text = "Evotec Services sp. z o.o.";
        table.Rows[0].Cells[2].Paragraphs[0].LineSpacingAfter = 0;
        table.Rows[0].Cells[2].Paragraphs[0].LineSpacingBefore = 0;

        table.Rows[0].Cells[2].Paragraphs[0].AddParagraph().AddText("ul. Drozdów 6");
        table.Rows[0].Cells[2].Paragraphs[1].LineSpacingAfter = 0;
        table.Rows[0].Cells[2].Paragraphs[1].LineSpacingBefore = 0;

        table.Rows[0].Cells[2].Paragraphs[1].AddParagraph().AddText("40-308, Mikołów");
        table.Rows[0].Cells[2].Paragraphs[2].LineSpacingAfter = 0;
        table.Rows[0].Cells[2].Paragraphs[2].LineSpacingBefore = 0;

        table.Rows[0].Cells[2].Paragraphs[2].AddParagraph().AddText("Poland");
        table.Rows[0].Cells[2].Paragraphs[3].LineSpacingAfter = 0;
        table.Rows[0].Cells[2].Paragraphs[3].LineSpacingBefore = 0;

        // lets hide the table visibility
        table.Style = WordTableStyle.TableNormal;

        // lets add some empty space
        document.AddParagraph();
        document.AddParagraph();

        // here's alternative way to build above
        var paragraph1 = document.AddParagraph("Evotec Services sp. z o.o.");
        paragraph1.LineSpacingAfter = 0;
        paragraph1.ParagraphAlignment = JustificationValues.Right;
        var paragraph2 = document.AddParagraph("ul. Drozdów 6");
        paragraph2.LineSpacingBefore = 0;
        paragraph2.LineSpacingAfter = 0;
        paragraph2.ParagraphAlignment = JustificationValues.Right;
        var paragraph3 = document.AddParagraph("40-308, Mikołów");
        paragraph3.LineSpacingBefore = 0;
        paragraph3.LineSpacingAfter = 0;
        paragraph3.ParagraphAlignment = JustificationValues.Right;
        var paragraph4 = document.AddParagraph("Poland");
        paragraph4.LineSpacingBefore = 0;
        paragraph4.LineSpacingAfter = 0;
        paragraph4.ParagraphAlignment = JustificationValues.Right;

        document.Save(openWord);
    }
}