Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Cell auto Fit during export to pdf

 Post Reply Post Reply
Author
Beketov Roman View Drop Down
New Member
New Member
Avatar

Joined: 21 Jul 2011
Posts: 22
Post Options Post Options   Quote Beketov Roman Quote  Post ReplyReply Direct Link To This Post Topic: Cell auto Fit during export to pdf
    Posted: 03 Jan 2013 at 8:33am
Hello.

We have an issue with exporting excel file to pdf in case excel has auto fit cells. When cell is set to wrap text and auto-fit to row height then during export to pdf auto fit is ignored and result pdf file looks incorrect.

We are using version 5.9.0 now.

When the issue can be fixed ?

Thanks.
Back to Top
Adrian Gallero View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 1237
Post Options Post Options   Quote Adrian Gallero Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 2013 at 10:28am
Hi,
I don't see this issue here, and it shouldn't happen, since FlexCel autofits wrapped cells.
I've tried it with the following code:

using System;
using FlexCel.XlsAdapter;
using FlexCel.Core;
using FlexCel.Render;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            XlsFile xls = new XlsFile(1, true);
            TFlxFormat fmt = xls.GetCellVisibleFormatDef(1, 1);
            fmt.WrapText = true;
            xls.SetCellValue(1, 1, "this is a long text that will be wrapped around", xls.AddFormat(fmt));
 
            xls.AutofitRowsOnWorkbook(truefalse, 1.1);
 
            xls.PrintGridLines = true;
            xls.PrintHeadings = true;
            using (FlexCelPdfExport pdf = new FlexCelPdfExport(xls, true))
            {
                pdf.Export("r:\\test.pdf");
            }
        }
    }
}

And I get this file, which looks fine:
http://tmssoftware.net/public/flexcel/test.pdf

If you run the code in your machine, do you see any difference?
Could it be that the issue is not with wrap text but with merged cells?  By default Excel won't autofit wrapped cells,
but FlexCel will. Now, if you open the file in Excel and left the row as autofit, Excel will reautofit the merged cell
to a single row. This is explained in the section "Autofitting Merged Cells" of UsingFlexCelAPI.pdf.
If the case is not because of merged cells, can you send me a reproducible example so I can take a look?

Regards,
   Adrian
Back to Top
Beketov Roman View Drop Down
New Member
New Member
Avatar

Joined: 21 Jul 2011
Posts: 22
Post Options Post Options   Quote Beketov Roman Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 2013 at 11:35am
Hello Adrian
Thanks!
Please try do the same on merged cells.
We will check this on our side as well.
Thank You!
Back to Top
Beketov Roman View Drop Down
New Member
New Member
Avatar

Joined: 21 Jul 2011
Posts: 22
Post Options Post Options   Quote Beketov Roman Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 2013 at 11:37am
Another question. When we copy workSheet to another file by flexcel does it copy auto fit and text wrap settings as well ?
Back to Top
Adrian Gallero View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 1237
Post Options Post Options   Quote Adrian Gallero Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 2013 at 2:51pm
yes, if you copy a full sheet, autofit and wrap settings are copied.
Now, just to be clear, FlexCel by default doesn't autofit rows even if they are autofit, this is by design (and explained in UsingFlexCelAPI.pdf) So you need to call AutofitAllRows in workbook before exporting to pdf. Are you calling it? If you are, with which parameters?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down