Ошибка нельзя установить свойство orientation класса pagesetup

I have written following code in .Net

excel = New Excel.Application
wBook = excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
wSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape

When i run this from local sytem it is working and when i copy this to a server and will be run from a service giving following error.

Unable to set the Orientation property of the PageSetup class

o11c's user avatar

o11c

15.2k4 gold badges50 silver badges75 bronze badges

asked Dec 6, 2010 at 8:08

Nag's user avatar

The PageSetup class of Excel must interact with the printer drivers on the server. If there are no printer drivers installed or access to them is restricted, any calls to this class with throw an exception.

You should ensure a default printer is set on the server and there are printer drivers installed. Also, if you are accessing this from ASP.net there are access issues and you should ensure the ASP.Net account has permission to access the printer. See this article which lays out some of the issues in more detail: http://support.microsoft.com/?id=291298

In general, if you are using Office 2007 or later you should avoid server-side automation as this can create unstable behavior — use the Open XML formats if possible. See http://support.microsoft.com/kb/257757

answered Jun 17, 2011 at 14:49

BgRva's user avatar

BgRvaBgRva

1,52112 silver badges26 bronze badges

2

I’m not sure if you are doing ASP.net application. But here’s what I got.

I have a ASP 4.0 and my code basically generate an excel file. Once excel file is generated, I export that to be a pdf. That’s causing the same issue u had.

The way to resolve it is to set the
Load User Profile to true
It’s under AppPool. right clicking it and you will see this property.

answered Jun 24, 2015 at 18:38

user5045942's user avatar

Check «default printer» in «Devices and Printers» page.

If any (redirected) printer is default change it. Default printer must not be any «redirected» one.

answered Aug 31, 2016 at 6:44

Can OTUR's user avatar

As BgRva pointed out, you need to install printer drivers. The PageSetup class of Excel must communicate with the printer drivers

I’m having similar issue running related code on Windows 8 operating under Mac Parallels (Virtual Machine). For anyone who are doing Visual Studio deployment on Mac Parallels, here’s what I’m doing:

  1. Disable Printers sharing between Mac and Windows. Go to Parallels
    (VM) > Configure > Hardware and click Print. Uncheck ‘Add all Mac
    printers’ and ‘Synchronize Default Printer’
  2. Install printer’s driver on Windows
  3. In order to get assigned IP address by the same wireless router
    (if you need to connect to printer wirelessly), you need to set up
    networking as bridged. Go to Parallels
    (VM) > Configure > Hardware > ‘Network 1’ and choose Networking type as Airport and DHCP server as Auto

answered Jan 2, 2014 at 15:54

Alphapico's user avatar

AlphapicoAlphapico

2,8532 gold badges30 silver badges29 bronze badges

Пользовательское соглашение

Политика конфиденциальности

© Николай Павлов, Planetaexcel, 2006-2023
info@planetaexcel.ru


Использование любых материалов сайта допускается строго с указанием прямой ссылки на источник, упоминанием названия сайта, имени автора и неизменности исходного текста и иллюстраций.

Техническая поддержка сайта

ООО «Планета Эксел»

ИНН 7735603520


ОГРН 1147746834949
        ИП Павлов Николай Владимирович
        ИНН 633015842586
        ОГРНИП 310633031600071 

Перейти к контенту

I have written following code in .Net

excel = New Excel.Application
wBook = excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
wSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape

When i run this from local sytem it is working and when i copy this to a server and will be run from a service giving following error.

Unable to set the Orientation property of the PageSetup class

o11c's user avatar

o11c

14.9k4 gold badges49 silver badges74 bronze badges

asked Dec 6, 2010 at 8:08

Nag's user avatar

The PageSetup class of Excel must interact with the printer drivers on the server. If there are no printer drivers installed or access to them is restricted, any calls to this class with throw an exception.

You should ensure a default printer is set on the server and there are printer drivers installed. Also, if you are accessing this from ASP.net there are access issues and you should ensure the ASP.Net account has permission to access the printer. See this article which lays out some of the issues in more detail: http://support.microsoft.com/?id=291298

In general, if you are using Office 2007 or later you should avoid server-side automation as this can create unstable behavior — use the Open XML formats if possible. See http://support.microsoft.com/kb/257757

answered Jun 17, 2011 at 14:49

BgRva's user avatar

BgRvaBgRva

1,43111 silver badges26 bronze badges

1

I’m not sure if you are doing ASP.net application. But here’s what I got.

I have a ASP 4.0 and my code basically generate an excel file. Once excel file is generated, I export that to be a pdf. That’s causing the same issue u had.

The way to resolve it is to set the
Load User Profile to true
It’s under AppPool. right clicking it and you will see this property.

answered Jun 24, 2015 at 18:38

user5045942's user avatar

Check «default printer» in «Devices and Printers» page.

If any (redirected) printer is default change it. Default printer must not be any «redirected» one.

answered Aug 31, 2016 at 6:44

Can OTUR's user avatar

As BgRva pointed out, you need to install printer drivers. The PageSetup class of Excel must communicate with the printer drivers

I’m having similar issue running related code on Windows 8 operating under Mac Parallels (Virtual Machine). For anyone who are doing Visual Studio deployment on Mac Parallels, here’s what I’m doing:

  1. Disable Printers sharing between Mac and Windows. Go to Parallels
    (VM) > Configure > Hardware and click Print. Uncheck ‘Add all Mac
    printers’ and ‘Synchronize Default Printer’
  2. Install printer’s driver on Windows
  3. In order to get assigned IP address by the same wireless router
    (if you need to connect to printer wirelessly), you need to set up
    networking as bridged. Go to Parallels
    (VM) > Configure > Hardware > ‘Network 1’ and choose Networking type as Airport and DHCP server as Auto

answered Jan 2, 2014 at 15:54

Alphapico's user avatar

AlphapicoAlphapico

2,8032 gold badges29 silver badges29 bronze badges

I have written following code in .Net

excel = New Excel.Application
wBook = excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
wSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape

When i run this from local sytem it is working and when i copy this to a server and will be run from a service giving following error.

Unable to set the Orientation property of the PageSetup class

o11c's user avatar

o11c

14.9k4 gold badges49 silver badges74 bronze badges

asked Dec 6, 2010 at 8:08

Nag's user avatar

The PageSetup class of Excel must interact with the printer drivers on the server. If there are no printer drivers installed or access to them is restricted, any calls to this class with throw an exception.

You should ensure a default printer is set on the server and there are printer drivers installed. Also, if you are accessing this from ASP.net there are access issues and you should ensure the ASP.Net account has permission to access the printer. See this article which lays out some of the issues in more detail: http://support.microsoft.com/?id=291298

In general, if you are using Office 2007 or later you should avoid server-side automation as this can create unstable behavior — use the Open XML formats if possible. See http://support.microsoft.com/kb/257757

answered Jun 17, 2011 at 14:49

BgRva's user avatar

BgRvaBgRva

1,43111 silver badges26 bronze badges

1

I’m not sure if you are doing ASP.net application. But here’s what I got.

I have a ASP 4.0 and my code basically generate an excel file. Once excel file is generated, I export that to be a pdf. That’s causing the same issue u had.

The way to resolve it is to set the
Load User Profile to true
It’s under AppPool. right clicking it and you will see this property.

answered Jun 24, 2015 at 18:38

user5045942's user avatar

Check «default printer» in «Devices and Printers» page.

If any (redirected) printer is default change it. Default printer must not be any «redirected» one.

answered Aug 31, 2016 at 6:44

Can OTUR's user avatar

As BgRva pointed out, you need to install printer drivers. The PageSetup class of Excel must communicate with the printer drivers

I’m having similar issue running related code on Windows 8 operating under Mac Parallels (Virtual Machine). For anyone who are doing Visual Studio deployment on Mac Parallels, here’s what I’m doing:

  1. Disable Printers sharing between Mac and Windows. Go to Parallels
    (VM) > Configure > Hardware and click Print. Uncheck ‘Add all Mac
    printers’ and ‘Synchronize Default Printer’
  2. Install printer’s driver on Windows
  3. In order to get assigned IP address by the same wireless router
    (if you need to connect to printer wirelessly), you need to set up
    networking as bridged. Go to Parallels
    (VM) > Configure > Hardware > ‘Network 1’ and choose Networking type as Airport and DHCP server as Auto

answered Jan 2, 2014 at 15:54

Alphapico's user avatar

AlphapicoAlphapico

2,8032 gold badges29 silver badges29 bronze badges

  • Remove From My Forums
  • General discussion

  • Hi,

    In the most recent release of a new service, we have a section of code that creates an Excel document and saves it in a location.  Nothing super complicated.  This service uses the 2003 Excel Interops (not my choice — it’s what is passed down
    to us from above as a requirement) to do this.

    Previous to this weekend’s install, the service was installed on Server 2003 and worked perfectly.  The production version that it lives on, however, is Server 2008.  Any time this service tries to create an Excel document it thows the error
    Unable to set the Orientation property of the PageSetup class.  It was not giving this error on 2003.

    After searching online the only things I can find tell me to install a default printer.  Which I did.  It did not fix anything.  The 2003 server didn’t have any installed anyway, so I don’t see this as the hinderance.

    Is this something weird with 2008 not installing the ASPNET user?  Maybe something else that I maybe don’t even know to guess?

    If anyone has any other ideas, they would be greatly appreciated.  At this point I’m at a loss as to what to even try.

    Thanks!

    • Changed type

      Monday, August 2, 2010 1:34 AM
      Duplcated post on the office forum

  • Remove From My Forums
  • General discussion

  • Hi,

    In the most recent release of a new service, we have a section of code that creates an Excel document and saves it in a location.  Nothing super complicated.  This service uses the 2003 Excel Interops (not my choice — it’s what is passed down
    to us from above as a requirement) to do this.

    Previous to this weekend’s install, the service was installed on Server 2003 and worked perfectly.  The production version that it lives on, however, is Server 2008.  Any time this service tries to create an Excel document it thows the error
    Unable to set the Orientation property of the PageSetup class.  It was not giving this error on 2003.

    After searching online the only things I can find tell me to install a default printer.  Which I did.  It did not fix anything.  The 2003 server didn’t have any installed anyway, so I don’t see this as the hinderance.

    Is this something weird with 2008 not installing the ASPNET user?  Maybe something else that I maybe don’t even know to guess?

    If anyone has any other ideas, they would be greatly appreciated.  At this point I’m at a loss as to what to even try.

    Thanks!

    • Changed type

      Monday, August 2, 2010 1:34 AM
      Duplcated post on the office forum

  • Remove From My Forums
  • Question

  • User1325737636 posted

    I have a web application that generates various reports in Excel or in Word and then downloads them to the client where they can be printed.  Even though there is nothing being printed on the web server, I want to properly format the reports
    in terms of page orientation, etc.  Everything is working great with Word.

    In Excel, whenever I try to change the page orientation to Landscape I get:

    COMException (0x800a03ec): Unable to set the Orientation property of the PageSetup class

    The single line of code that is causing this is:

    mySheet.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;

    If I comment out the line everything else works like a champ.  The code also works fine when I test it on my local computer (without the line commented out).

    On the server, the web application runs with the username CCSUser.  I can log onto the server using that username, bring up Excel manually, create some sort of spreadsheet, and set the orientation of that spreadsheet to Landscape.  It works fine.
     It just does not work when I try to do it from my C# code.

    There is no physical printer attached to the server.  The default printer for the account used by the web application is Microsoft XPS Document Writer.  The security permissions on that printer allow me to Print, Manage the Printer, and Manage Documents.

    We had the same problem before our recent upgrade from Windows Server 2000 to 2008.  I had hoped that it might magically go away when we upgraded.  It didn’t.

    What am I doing wrong?

    Thanks.

Я написал следующий код в .Net

excel = New Excel.Application
wBook = excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
wSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape

Когда я запускаю это из локальной системы, он работает и когда я копирую его на сервер и запускаюсь из службы, предоставляющей следующую ошибку.

Невозможно установить свойство Orientation класса PageSetup

Класс PageSetup Excel должен взаимодействовать с драйверами принтера на сервере. Если нет установленных драйверов принтера или доступа к ним, любые вызовы этого класса с вызовом исключения.

Вы должны убедиться, что на сервере установлен принтер по умолчанию, и установлены драйверы принтера. Кроме того, если вы получаете доступ к этому из ASP.net, есть проблемы с доступом, и вы должны убедиться, что учетная запись ASP.Net имеет разрешение на доступ к принтеру. См. Эту статью, в которой излагаются некоторые из вопросов более подробно: http://support.microsoft.com/?id=291298

В общем случае, если вы используете Office 2007 или более позднюю версию, вам следует избегать автоматизации на стороне сервера, так как это может привести к нестабильному поведению — если возможно, используйте форматы Open XML. См. http://support.microsoft.com/kb/257757

Я не уверен, что вы используете приложение ASP.net. Но вот что я получил.

У меня есть ASP 4.0, и мой код в основном генерирует файл excel. После создания файла excel я экспортирую его в pdf. Это вызывает ту же проблему, что и у вас.

Способ решения проблемы — установить
Загрузите профиль пользователя в true
Это под AppPool. щелкнув правой кнопкой мыши, и вы увидите это свойство.

Как указывал BgRva, вам необходимо установить драйверы принтера. Класс PageSetup Excel должен взаимодействовать с драйверами принтера

У меня есть аналогичная проблема с запущенным связанным кодом в Windows 8, работающим под Mac Parallels (Virtual Machine). Для тех, кто занимается развертыванием Visual Studio на Mac Parallels, вот что я делаю:

    Отключить использование принтеров между Mac и Windows. Перейти к Parallels
    (VM) > Настроить > Оборудование и нажмите «Печать». Снимите флажок «Добавить все Mac
    принтеры и «Синхронизировать принтер по умолчанию»
    Установить драйвер принтера в Windows
    Чтобы получить назначенный IP-адрес одним и тем же беспроводным маршрутизатором
    (если вам необходимо подключиться к принтеру по беспроводной сети), вам необходимо настроить
    сеть как мост. Перейти к Parallels
    (VM) > Настроить > Оборудование > «Сеть 1» и выберите «Тип сети» как «Аэропорт» и «Сервер DHCP» как «Авто»

Проверьте «принтер по умолчанию» на странице «Устройства и принтеры».

Если какой-либо (перенаправленный) принтер по умолчанию изменит его. Принтер по умолчанию не должен быть «перенаправлен».

Введите минимум 50 символов

  • Remove From My Forums
  • Вопрос

  • Hi,

    In the most recent release of a new service, we have a section of code that creates an Excel document and saves it in a location.  Nothing super complicated.  This service uses the 2003 Excel Interops (not my choice — it’s what is passed down
    to us from above as a requirement) to do this.

    Previous to this weekend’s install, the service was installed on Server 2003 and worked perfectly.  The production version that it lives on, however, is Server 2008.  Any time this service tries to create an Excel document it thows the error
    Unable to set the Orientation property of the PageSetup class.  It was not giving this error on 2003.

    After searching online the only things I can find tell me to install a default printer.  Which I did.  It did not fix anything.  The 2003 server didn’t have any installed anyway, so I don’t see this as the hinderance.

    If anyone has any other ideas, they would be greatly appreciated.  At this point I’m at a loss as to what to even try.

    Thanks!

    • Изменено

      26 июля 2010 г. 14:42
      formatting

Я написал следующий код в.Net

excel = New Excel.Application
wBook = excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
wSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape

Когда я запускаю это из локальной системы, он работает, и когда я копирую это на сервер, он запускается из службы, выдающей следующую ошибку.

Невозможно установить свойство Orientation класса PageSetup

2010-12-06 08:08

4
ответа

Класс PageSetup в Excel должен взаимодействовать с драйверами принтера на сервере. Если драйверы принтера не установлены или доступ к ним ограничен, любые вызовы этого класса с исключением.

Убедитесь, что на сервере установлен принтер по умолчанию и установлены драйверы принтера. Кроме того, если вы обращаетесь к нему через ASP.net, существуют проблемы с доступом, и вы должны убедиться, что у учетной записи ASP.Net есть разрешение на доступ к принтеру. См. Эту статью, в которой более подробно рассматриваются некоторые проблемы: http://support.microsoft.com/?id=291298

В целом, если вы используете Office 2007 или более позднюю версию, вам следует избегать автоматизации на стороне сервера, поскольку это может привести к нестабильному поведению — по возможности используйте форматы Open XML. См. http://support.microsoft.com/kb/257757

2011-06-17 14:49

Проверьте «принтер по умолчанию» на странице «Устройства и принтеры».

Если какой-либо (перенаправленный) принтер используется по умолчанию, измените его. Принтер по умолчанию не должен быть перенаправленным.

2016-08-31 06:44

Я не уверен, что вы делаете приложение ASP.net. Но вот что я получил.

У меня есть ASP 4.0, и мой код в основном генерирует файл Excel. После создания файла Excel я экспортирую его в формат PDF. Это вызывает ту же проблему, что и у вас.

Чтобы решить эту проблему, установите True для профиля пользователя. Он находится в AppPool. щелкните правой кнопкой мыши, и вы увидите это свойство.

2015-06-24 18:38

Как указала BgRva, вам необходимо установить драйверы принтера. Класс PageSetup в Excel должен взаимодействовать с драйверами принтера

У меня похожая проблема при запуске связанного кода в Windows 8, работающей под Mac Parallels (виртуальная машина). Для тех, кто занимается развертыванием Visual Studio на Mac Parallels, вот что я делаю:

  1. Отключите общий доступ к принтерам между Mac и Windows. Перейдите в Parallels
    (VM) > Настроить> Оборудование и нажмите Печать. Снимите флажок «Добавить все принтеры Mac» и «Синхронизировать принтер по умолчанию»
  2. Установите драйвер принтера в Windows
  3. Чтобы получить назначенный IP-адрес одним и тем же беспроводным маршрутизатором (если вам необходимо подключиться к принтеру по беспроводной сети), вам нужно настроить сеть как мостовую. Перейдите в Parallels
    (VM) > Конфигурировать> Оборудование> «Сеть 1» и выберите «Тип сети» в качестве аэропорта и DHCP-сервер в качестве «Авто»

2014-01-02 15:54

Другие вопросы по тегам
.net

Я написал следующий код в .Net

excel = New Excel.Application
wBook = excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
wSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape

Когда я запускаю это из локальной системы, он работает и когда я копирую его на сервер и запускаюсь из службы, предоставляющей следующую ошибку.

Невозможно установить свойство Orientation класса PageSetup

Класс PageSetup Excel должен взаимодействовать с драйверами принтера на сервере. Если нет установленных драйверов принтера или доступа к ним, любые вызовы этого класса с вызовом исключения.

Вы должны убедиться, что на сервере установлен принтер по умолчанию, и установлены драйверы принтера. Кроме того, если вы получаете доступ к этому из ASP.net, есть проблемы с доступом, и вы должны убедиться, что учетная запись ASP.Net имеет разрешение на доступ к принтеру. См. Эту статью, в которой излагаются некоторые из вопросов более подробно: http://support.microsoft.com/?id=291298

В общем случае, если вы используете Office 2007 или более позднюю версию, вам следует избегать автоматизации на стороне сервера, так как это может привести к нестабильному поведению — если возможно, используйте форматы Open XML. См. http://support.microsoft.com/kb/257757

Я не уверен, что вы используете приложение ASP.net. Но вот что я получил.

У меня есть ASP 4.0, и мой код в основном генерирует файл excel. После создания файла excel я экспортирую его в pdf. Это вызывает ту же проблему, что и у вас.

Способ решения проблемы — установить
Загрузите профиль пользователя в true
Это под AppPool. щелкнув правой кнопкой мыши, и вы увидите это свойство.

Как указывал BgRva, вам необходимо установить драйверы принтера. Класс PageSetup Excel должен взаимодействовать с драйверами принтера

У меня есть аналогичная проблема с запущенным связанным кодом в Windows 8, работающим под Mac Parallels (Virtual Machine). Для тех, кто занимается развертыванием Visual Studio на Mac Parallels, вот что я делаю:

    Отключить использование принтеров между Mac и Windows. Перейти к Parallels
    (VM) > Настроить > Оборудование и нажмите «Печать». Снимите флажок «Добавить все Mac
    принтеры и «Синхронизировать принтер по умолчанию»
    Установить драйвер принтера в Windows
    Чтобы получить назначенный IP-адрес одним и тем же беспроводным маршрутизатором
    (если вам необходимо подключиться к принтеру по беспроводной сети), вам необходимо настроить
    сеть как мост. Перейти к Parallels
    (VM) > Настроить > Оборудование > «Сеть 1» и выберите «Тип сети» как «Аэропорт» и «Сервер DHCP» как «Авто»

Проверьте «принтер по умолчанию» на странице «Устройства и принтеры».

Если какой-либо (перенаправленный) принтер по умолчанию изменит его. Принтер по умолчанию не должен быть «перенаправлен».

Введите минимум 50 символов

Понравилась статья? Поделить с друзьями:
  • Ошибка нельзя скачать альбион онлайн
  • Ошибка нельзя скачать live albiononline com autoupdate manivest xml
  • Ошибка нельзя открыть каталог он открыт другим приложением
  • Ошибка нельзя изменить часть массива excel что делать
  • Ошибка нексус мод менеджер скайрим unrecognized