C excel range — Мир ПК

Work with Excel Ranges

A Range represents a selection of one or more cells in Excel.

With IronXL we can Read, Add, Sum, Average, Min, Max and Set Values over any Range of Cells.

Reading & Writing Excel Files in C#.

Human Support

Talk directly with our development team

Documentation

Clear online manuals in plain English.

Simple Licensing

Free development license. Commercial from $399.

Get Started Now

Get started in minutes with NuGet or DLL.

Try IronXL for Free

Get Set Up in 5 Minutes

Download DLL

2019.3.2.1

Manually install into your project

  1. Download and unzip IronXL to a location such as

/Libs within your Solution directory

  • In Visual Studio Solution Explorer, right click References. Select Browse, «IronXL.dll»
  • Install with NuGet

    2019.3.2.1

    1. In Solution Explorer, right-click References, Manage NuGet Packages
    2. Select Browse and search «IronXL»
    3. Select the package and install

    Have a question? Get in touch with our development team.

    IronXL End User License Agreement

    Iron Software LLC hereby grants you a non-exclusive license to the IronXL Software Library for .Net («the Software»).

    Do No Harm

    By downloading or using the Software, the Licensee agrees not to utilize the software in a manner which is disparaging to Iron Software LLC, and not to rent, lease or otherwise transfer rights to the Software. The Licensee agrees that no attempt will be made by the Licensee or associated parties to translate, reverse engineer, modify, decompile, disassemble or distribute the Software.

    License Types

    License terms are offered on the following terms, as purchased. If no purchase or insufficient purchase has been made then the Free Trial License terms apply.

    1) Free Trial License — Grants the use of the TRIAL VERSION of the software for private evaluation purposes only. The Software should not be published in any internet, software, SaaS nor intranet project.

    2) Single Project License — Grants the use of the Software by a specified number of software developer. They software may be deployed within ONE web-application, intranet application or desktop software application, for the use of ONE end user organization. Not valid for OEM redistribution or SaaS services.

    3) Advanced Developer License — Grants the use of The Software for 1 developer and unlimited end user organizations. The Software is licensed for use within an agreed number of software projects. Valid for development, staging and production servers. Not valid for OEM redistribution or SaaS services. This license is perpetual with no yearly fees.

    Читать еще:  Способы копирования в excel

    4) Single Site Organization License — Grants the use of the Software by a specified number developers to create and deploy software for the end use of ONE business OR ONE government department OR ONE legal entity in a single location («The Organization») . This license covers unlimited applications or projects The Software may be deployed upon any number of machines the end-use of The Organization. Not valid for OEM redistribution or SaaS services.

    5) Global Enterprise License — Grants the use of the Software by a specified number developers to create and deploy software for the end use of ONE business OR ONE government department OR ONE legal entity («The Organization») in multiple locations. This license covers unlimited applications or projects The Software may be deployed upon any number of machines the end-use of The Organization. Not valid for OEM redistribution or SaaS services.

    6) Agency License — Grants the use of The Software for unlimited developers and unlimited end user organizations, but is restrticted by the number of purchased project deployments. The Software is licensed for use within an agreed number of software projects. This license also intrinsically covers for development, staging and production servers for each project. Not valid for OEM redistribution or SaaS services.

    7) SaaS License — Grants the use of the Software by unlimited developers to deploy within ONE single a single SaaS software service where Excel editing is not a primary business function. Valid for development, staging and production servers. Not valid for OEM redistribution.

    8) OEM Redistribution License — Grants the right to distribute the Software (without royalty) as part of ONE distinct packaged commercial product, provided that your application is not a software development system or tool, nor a Excel spreadsheet editing application in its self.

    Ownership

    Iron Software LLC shall at all times retain ownership of the Iron Barcode Software Library and all subsequent copies.

    Copyright

    Title, ownership rights, and intellectual property rights in and to the Software shall remain with Iron Software LLC. The Software is protected by the international copyright laws. Title, ownership rights, and intellectual property rights in and to the content accessed through the Software is the property of the applicable content owner and may be protected by applicable copyright or other law. This License gives you no rights to such content.

    Upgrades & Support

    If a new release of the software is produced within 12 months from the date of purchase then you will be entitled to a free upgrade. This agreement may be extended by explicit purchase of additional lights. This license does not grant you any right to any enhancement or update beyond the initial 12 month period, commencing from the date of purchase. This license does not indicate a Service Level Agreement, nor does it imply that Iron Software is responsabile for sucessful deployment, maintainance nor business function of The Software.

    Читать еще:  Фигурная диаграмма в excel

    Limitation Of Liability

    THIS SOFTWARE IS PROVIDED «AS IS,» WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. IRON SOFTWARE AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL IRON SOFTWARE OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF IRON SOFTWARE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

    Miscellaneous

    This software is not designed or intended for use in on-line control of aircraft, air traffic, aircraft navigation or aircraft communications; or in the design, construction, operation or maintenance of any nuclear facility. Licensee represents and warrants that it will not use or redistribute the Software for such purposes.

    Работа с Excel с помощью C# (Microsoft.Office.Interop.Excel)

    Оставляю заметку по работе с Excel с помощью C#.

    Привожу фрагменты кода, которые искал когда-то сам для работы с Excel документами.

    Наработки очень пригодились в работе для формирования отчетности.

    Прежде всего нужно подключить библиотеку Microsoft.Office.Interop.Excel.

    Visual Studio здесь довольно старой версии. Если у вас версия новая, отличаться будет только вид окна.

    Далее создаем псевдоним для работы с Excel:

    using Excel = Microsoft.Office.Interop.Excel;

    Расстановка рамок.

    Расставляем рамки со всех сторон:

    Цвет рамки можно установить так:

    Выравнивания в диапазоне задаются так:

    Формулы

    Определим задачу: получить сумму диапазона ячеек A4:A10.

    Для начала снова получим диапазон ячеек:

    Excel.Range formulaRange = sheet.get_Range(sheet.Cells[4, 1], sheet.Cells[9, 1]);

    Далее получим диапазон вида A4:A10 по адресу ячейки ( [4,1]; [9;1] ) описанному выше:

    string adder = formulaRange.get_Address(1, 1, Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing);

    Теперь в переменной adder у нас хранится строковое значение диапазона ( [4,1]; [9;1] ), то есть A4:A10.

    Выделение ячейки или диапазона ячеек

    Так же можно выделить ячейку или диапазон, как если бы мы выделили их мышкой:

    Читать еще:  просмотреть видео с ютуба телеграмм

    Авто ширина и авто высота

    Чтобы настроить авто ширину и высоту для диапазона, используем такие команды:

    Получаем значения из ячеек

    Чтобы получить значение из ячейки, используем такой код:

    Добавляем лист в рабочую книгу

    Чтобы добавить лист и дать ему заголовок, используем следующее:

    Добавление разрыва страницы

    Сохраняем документ

    Как открыть существующий документ Excel

    Комментарии

    При работе с Excel с помощью C# большую помощь может оказать редактор Visual Basic, встроенный в Excel.

    Для этого в настройках ленты надо добавить пункт «Разработчик». Далее начинаем запись макроса, производим действия и останавливаем запись.

    Далее заходим в редактор Visual Basic и смотрим код, который туда записался:

    В данном макросе записаны все действия, которые мы выполнили во время его записи. Эти методы и свойства можно использовать в C# коде.

    Данный метод так же может оказать помощь в формировании относительных формул, например, выполнить сложение чисел, находящиеся слева от текущей ячейки на 4 столбца, и т.п. Пример:

    Так же во время работы может возникнуть ошибка: метод завершен неверно. Это может означать, что не выбран лист, с которым идет работа.

    Чтобы выбрать лист, выполните sheetData.Select(Type.Missing); где sheetData это нужный лист.

    Работа с Excel с помощью C# (Microsoft.Office.Interop.Excel): 11 комментариев

    Как прочитать данные из ячейки excel,и записать эти данные в sql server?

    Добрый день.
    Отправил на почту.

    Добрый день.
    А мне можно тоже самое?)

    Здравствуйте, как изменить цвет диаграммы при работе в C#?(круговая диаграмма)

    Вы можете записать макрос на изменение цвета в Visual Basic и списать получившийся код. Затем использовать его в своей программе.

    Здравствуйте.
    Можете подсказать, как «заставить» приложение работать с разными версиями MS Office? На машине разработчика стоит Office 2010, при запуске на машине с 2003-м — увы — ошибка.

    Microsoft.Office.Interop.Excel это довольно старый способ работать с Excel документами.
    Что касается версии Office 2003, то он использует совсем другой драйвер.
    Соответственно версия Microsoft.Office.Interop.Excel.dll нужна старая, плюс драйвер microsoft jet 4.0, который на новых системах (Win 8, 10) работает неправильно.
    Единственное, что могу посоветовать, так это просмотреть Microsoft Office Compatibility Pack для Office 2003, чтобы научить его открывать xslx документы.
    А в своей программе использовать не Interop.Excel, а библиотеку EPPlus. Она работает с excel документами, используя технологию OpenXml и не надо париться по поводу драйверов.
    Код будет очень похож на Interop.Excel-ный.

    Очень полезная штука, спасибо за удобное представление информации на Вашем сайте!

    Скажите пожалуйста, как прочитать данные из ячейки Excel и записать их в SQL Server?

    Запись опубликована в рубрике Excel. Добавьте в закладки постоянную ссылку.