Spreadsheet Workbench/ru

Введение
Верстак электронных таблиц позволяет создать и редактировать электронные таблицы, использовать данные из электронной таблицы как параметр в модели, заполнять таблицу данными из модели, выполнять вычисления, и экспортировать данные в другие приложения текстовых таблиц, такие как LibreOffice или Microsoft Excel.



Инструменты

 * Spreadsheet_CreateSheet.svg Create sheet: создать новую электронную таблицу.


 * Spreadsheet_Import.svg Import: import a CSV file into a spreadsheet.


 * Spreadsheet_Export.svg Export: export a CSV file from a spreadsheet.


 * Spreadsheet_MergeCells.svg Merge cells: merge selected cells.


 * Spreadsheet_SplitCell.svg Split cell: split previously merged cells.


 * Spreadsheet_AlignLeft.svg Align left: align the contents of selected cells to the left.


 * Spreadsheet_AlignCenter.svg Align center: align the contents of selected cells to the center horizontally.


 * Spreadsheet_AlignRight.svg Align right: align the contents of selected cells to the right.


 * Spreadsheet_AlignTop.svg Align top: align the contents of selected cells to the top.


 * Spreadsheet_AlignVCenter.svg Align vertical center: align the contents of selected cells to the center vertically.


 * Spreadsheet_AlignBottom.svg Align bottom: top align the contents of selected cells to the bottom.


 * Spreadsheet_StyleBold.svg Style bold: set the contents of selected cells to bold.


 * Spreadsheet_StyleItalic.svg Style italic: set the contents of selected cells to italic.


 * Spreadsheet_StyleUnderline.svg Style underline: set the contents of selected cells to underlined.


 * Spreadsheet_SetAlias.svg Set alias: установить псевдоним для выбранных ячеек.


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

Preferences

 * [[Image:Preferences-spreadsheet.svg|32px]] Preferences: the preferences for the Spreadsheet Workbench.

Insert and remove rows and columns
Rows and columns can be inserted or removed by right-clicking a row or column header and selecting the appropriate option from the contex menu. It is possible to select multiple rows or columns first. Either by holding down the key while selecting the headers, or by holding down the left mouse button and dragging.

In FreeCAD version 0.19 and earlier rows are inserted above the selected rows, and columns on the left of the selected columns. In FreeCAD version 0.20 you can specify the insertion side.

Note that removing rows or columns with data can break the spreadsheet and your model if it relies on the spreadheet. You are not prewarned if this happens.

Cut and copy-paste cells
Cut and copy-paste operations can be used on cells in FreeCAD spreadsheets. You can use the normal shortcuts for these operations: +, + and + respectively. To select multiple cells hold down the key while selecting, or hold down the left mouse button and drag to select a rectangular cell range.

The cut and copy operations store the contents and properties of the cells on the Clipboard. The paste operation writes the data in such a way that the content of the top left cell of the stored data is dropped in the active cell. Other stored content is placed relative to that cell. Formulas are updated accordingly.

Note that removing cells with data can break the spreadsheet and your model if it relies on the spreadheet. You are not prewarned if this happens.

In FreeCAD version 0.19 and earlier there is a bug that can cause FreeCAD to hang if a non-rectangular cell range is pasted. It is advisable to save your work before performing any paste operations.

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



Как указано на вкладках, можно изменить следующие свойства:


 * Цвет: цвет текста и цвет фона.
 * Выравнивание: выравнивание текста по горизонтали и вертикали
 * Стиль: стиль текста: полужирный, курсив, подчеркивание.
 * Единицы:  Отображение единиц измерения для этой ячейки. Прочтите раздел Единицы измерения ниже.
 * Псевдоним:  Определение псевдонима для этой ячейки. Этот псевдоним можно использовать в формулах ячеек, а также в общих выражениях; смотри раздел данные электронных таблиц в выражениях для получения дополнительной информации.

Выражения в ячейках
Ячейка таблицы может содержать любой текст или выражение. Технически, выражение должно начинаться со знака равенства '='. Однако, таблица пытается быть умной, и если Вы введёте нечто, похожее на выражение, но без начального знака '=', он будет добавлен автоматически.

Выражения ячеек могут содержать числа, функции, ссылки на другие ячейки и ссылки на свойства модели. (Но смотрите текущие ограничения ниже). Ссылки на ячейки по их столбцам (ЗАГЛАВНЫЕ буквы) и строкам (числа). На ячейки можно так же ссылаться по их псевдонимам (см. ниже). Пример: B4 + A6

Примечание: Выражения в ячейках обрабатываются FreeCAD как программный код. Поэтому при редактировании ячеек видимое содержимое не следует настройкам дисплея:
 * десятичный разделитель всегда точка
 * число показываемых десятичных чисел может отличаться от настроек

Ссылки на объекты в модели описаны в разделе Ссылки на данные САПР. Использование значений ячеек для определения параметров моделей описано в разделе Данные таблицы в выражениях. Насчёт дополнительной информации о выражениях и доступных функциях, смотрите Выражения.

Взаимодействие между электронными таблицами и моделью САПР
Данные в ячейках электронной таблицы могут использоваться в выражениях параметров модели САПР. Таким образом, электронная таблица может использоваться как источник значений параметров, используемых во всей модели, эффективно собирая значения в одном месте. Когда значения изменяются в электронной таблице, они распространяются по всей модели.

Точно так же свойства из объектов модели САПР могут использоваться в выражениях в ячейках электронной таблицы. Это позволяет использовать такие свойства объекта, как объем или площадь в электронной таблице. Если имя объекта в модели САПР изменяется, изменение автоматически распространяется на все ссылки в выражениях в электронной таблице, использующих изменённое имя.

В одном документе можно использовать более одной электронной таблицы; электронным таблицам можно давать присвоенное пользователем имя (переименовывать), как и любому другому объекту.

FreeCAD will automatically assign a unique name to a spreadsheet when it is created. These names follow the pattern, , and so on. The name can not be changed, and it is not visible in the properties of the spreadsheet. It can be used to refer to the spreadsheet in an Expression (see Spreadsheet data in expressions below.)

The label of a spreadsheet is automatically set to the name of the spreadsheet upon creation. Unlike the name, the label can be changed, for example in the properties panel or using the context menu action Rename. By default FreeCAD does not accept duplicate labels, but there is a preference to override this. Spreadsheets with duplicate labels in the same document cannot be referenced by their label.

FreeCAD проверяет на циклические зависимости. Смотрите в разделе Текущие ограничения.

Ссылки на данные САПР
Как указано выше, можно ссылаться на данные из модели САПР в выражениях электронной таблицы.

В следующей таблице показаны некоторые примеры, предполагающие, что модель имеет функцию с именем «MyCube»:

Данные таблицы в выражениях
In order to use spreadsheet data in other parts of FreeCAD, you will usually create an Expression that refers to the spreadsheet and the cell that contains the data you want to use. You can identify spreadsheets by name or by label, and you can identify the cells by address or by alias. Autocompletion is available for all forms of referencing.

The recommended way to refer to spreadsheet data is to use the spreadsheet label and cell alias name. For a more in-depth explanation of the pros and cons of the referencing modes, see the expanded section below.

Using the spreadsheet label has the advantage that it can be freely changed to describe the contents of the spreadsheet. It is also easier to identify the spreadsheet that is being used since the text in the expression matches the label shown in the model and property views. If you decide to change the label of a spreadsheet, existing references to the contents of the spreadsheet will be updated, so you won't break your expressions by renaming the spreadsheet. The internal name of the spreadsheet is not readily available anywhere except within the expression editor, so if you use the internal name and later decide to rename the spreadsheets, you might have a hard time tracing your expression data back to its source.

Be aware that when you create a new spreadsheet, the name and the label are the same, so it is easy to accidentally use the spreadsheet name instead of the label. A simple way to avoid this is to give the spreadsheet a meaningful name before starting to use it in expressions.

While you may use the row and column number in an expression to reference a cell, best practice is to give the cell an alias name and use that. See Cell properties on how to set the alias. For example, if the data in cell B1 contained the length parameter for an object, an alias name of would allow the value to be referred to as  instead of. Besides being much easier to read and understand, alias names are also much easier to change if you decide to adjust the structure of your spreadsheet. Using an alias also has the advantage that it is reasier to see which cells are used to control other parts of the document. Note that FreeCAD will automatically adjust the positional references in expressions if you insert or remove rows and columns in the spreadsheet, so even if you use row and column numbers in an expression, you can insert rows and columns without breaking the references to the surrounding cells.

Complex models and recomputes
Editing a spreadsheet will trigger a recompute of the 3D model, even if the changes do not affect the model. For a complex model a recompute can take a long time, and having to wait after every single edit is of course quite annoying.

There are three solutions to deal with this:
 * 1) Temporarily skip recomputes:
 * 2) * In the Tree view right-click the [[Image:Document.svg|24px]] document that contains the spreadsheet.
 * 3) * Select the option from the context menu.
 * 4) * There is a big disadvantage to this solution. New values entered in the spreadsheet will not be displayed until the document is recomputed. Instead is shown.
 * 5) * You can either recompute manually, using the Std Refresh command, or disable when you are done editing.
 * 6) Use a macro to automatically skip recomputes while editing a spreadsheet:
 * 7) * Download and run skipSheet.FCMacro.
 * 8) * This solution saves a few steps compared to the first solution, but also has the mentioned disadvantage.
 * 9) Put the spreadsheet in a separate FreeCAD file:
 * 10) * You can reference spreadsheet data from an external file with this syntax:.
 * 11) * The advantage of having the spreadsheet in another file over switching off recomputes is that the spreadsheet itself does get recomputed.
 * 12) * The disadvantage is that the model won't automatically recompute after changes to the spreadsheet.
 * 13) * In the scenario where you first open the 'spreadsheet' file, change one or more values and then open the 'model' file, there won't be any indication that the model needs to be recomputed. But if both files are open the Std Refresh icon will update correctly for the 'model' file after changes to the 'spreadsheet' file.

Единицы измерения
The Spreadsheet has a notion of dimension (units) associated with cell values. A number entered without an associated unit has no dimension. The unit should be entered immediately following the number value, with no intervening space. If a number has an associated unit, that unit will be used in all calculations. For example, the multiplication of two lengths with the unit mm gives an area with the unit mm&sup2;.

If a cell contains a value which represents a dimension, it should be entered with its associated unit. While in many simple cases one can get by with a dimensionless value, it is unwise to not enter the unit. If a value representing a dimension is entered without its associated unit, there are some sequences of operations which cause FreeCAD to complain of incompatible units in an expression when it appears the expression should be valid. (This may be better understood by viewing this thread in the FreeCAD forums.)

You can change the units displayed for a cell value using the Cell properties dialog. This does not change the value contained in the cell; it only converts the existing value for display. The value used for calculations does not change, and the results of formulas using the value do not change. For example, a cell containing the value "5.08cm" can be displayed as "2in" by changing the units tab value to "in".

A dimensionless number cannot be changed to a number with a unit by the cell properties dialog. One can put in a unit string, and that string will be displayed; but the cell still contains a dimensionless number. In order to change a dimensionless value to a value with a dimension, the value itself must be re-entered with its associated unit.

Occasionally it may be desirable to get rid of a dimension in an expression. This can be done by multiplying by 1 with a reciprocal unit.

CSV format
FreeCAD spreadsheets can be imported and exported to the CSV format which can also be read and written by most other spreadsheet applications such as Microsoft Excel or LibreOffice Calc. See Spreadsheet Import and Spreadsheet Export for more information.

XLSX format
Spreadsheets in the Excel-format XLSX can be imported with the Std Import command or the Std Open command. The following features are supported:


 * All functions that are also available in the FreeCAD spreadsheet. Other functions give an error in the corresponding cell after import.
 * Alias names for cells.
 * More than one sheet in the Excel-spreadsheet. In this case one FreeCAD spreadsheet is created for each Excel sheet.

Other functionality is not imported into the FreeCAD spreadsheet.

Printing
To handle the page setup necessary for printing, FreeCAD spreadsheets are printed by inserting them into a TechDraw Spreadsheet View.

Текущие ограничения
FreeCAD проверяет циклические зависимости. По задумке эта проверка останавливается на уровне объекта электронной таблицы. Как следствие, у вас не должно быть электронной таблицы, содержащей как ячейки, значения которых используются для определения параметров модели, так и ячейки, значения которых используют выходные данные модели. Например, у вас не может быть ячеек, определяющих длину, ширину и высоту объекта, и другой ячейки, которая ссылается на общий объем полученной формы. Это ограничение можно преодолеть с помощью двух электронных таблиц: одна используется в качестве источника данных для входных параметров модели, а другая используется для расчётов на основе результирующих геометрических данных.

Cell binding
It is possible to bind the content of cells to other spreadsheet cells. This can be useful when dealing with large tables or to get cell content from another spreadsheet.

Create binding
To bind, for example, the cell range A3-C4 to the cell range B1-D2:

  Select the cell range A3-C4.   Right-click and select from the context menu.   The dialog opens.   Set the range B1-D2 for the :   Press.   Bound cells have a blue border to highlight the binding.   If you now enter something in cell C1, the same will immediately appear in cell B3. </li> </ol>



Change binding

 * 1) Right-click a bound cell (there is no need to highlight the whole bound range) and select  from the context menu.
 * 2) The  dialog opens.
 * 3) Change one or more options. Note that the, the bound cell range, cannot be changed.
 * 4) Press.

Remove binding

 * 1) Right-click a bound cell (there is no need to highlight the whole bound range) and select  from the context menu.
 * 2) The  dialog opens.
 * 3) Press.

Configuration tables
You can use Spreadsheets to create configuration tables with sets of predefined parameters for your model, and then dynamically change which configuration to use. See this Forum post if you want to know more about the inner workings of this feature.

Expand this section for a brief tutorial on creating a configuration table.

<ol>  In a new document, first create a Std Part, then create a Part Box, a Part Cylinder and a Spreadsheet. </li>  The Box and the Cylinder are automatically placed in the Std Part container. Manually put the Spreadsheet in the container as well. </li>  In the Spreadsheet enter the content as shown below. Set the alias for B2 as, C2 as and D2 as : </li>  Bind the expressions and  to the Box's properties  and, respectively: </li>  Bind the expression to the Cylinder's property. Also change the of the Cylinder to  so that it is lower than the Box. </li>  Right-click the cell A2 in the Spreadsheet and select from the context menu. </li>  The dialog opens. </li>  Enter the following: </li>  Press. </li>  A new property called is be added to the Std Part container to choose the configuration as shown below: </li> </ol>

You can use either a Std Link or a PartDesign SubShapeBinder to instantiate a Variant Instance of a configurable object with the following steps:


 * 1) Create a Std Link to the Std Part container and set its  property to.
 * 2) Move the Link to a new place by changing its  so that it is easier to distinguish from the original object.
 * 3) Select a different  for the Link to create a variant instance.

Similar steps apply to a PartDesign SubShapeBinder, except that its property for activating a variant instance is called.