Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: ClosedXml doesn't copy printer settings

$
0
0
Hi,
I have xltx Excel's template, when I create (manually) new document from it and click File->Print in Excel first sheet fits on one page.

Than I create new document from my template with the help of ClosedXml:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClosedXML.Excel;

namespace ClosedXml1
{
    class Program
    {
        staticvoid Main(string[] args)
        {
            var tXltx = "t.xltx";
            using (XLWorkbook workbook = new XLWorkbook(tXltx))
            {
                using (XLWorkbook newWb = new XLWorkbook())
                {
                    foreach (XLWorksheet worksheet in workbook.Worksheets.Reverse())
                    {
                        worksheet.CopyTo(newWb, worksheet.Name, 1);
                    }

                    newWb.SaveAs("new.xlsx");
                }
            }
        }
    }
}
When I open resulting document and open printing dialog (File->Print) first sheet doesn't fit on one page.

So there are questions:
  1. What has to be copied from original template that resulting sheet fits one page?
  2. Is there any way to accomplish it?
(Here is a SO question)

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>