java excel根据数据自动调整列高 java设置excel列宽_vba

excel设置行高等于列宽

java excel根据数据自动调整列高 java设置excel列宽_postgresql_02

By default, when you create a new workbook in Excel, the row height and column width is always the same for all cells. However, you can easily change the height and width for one or more rows and columns.

默认情况下,当您在Excel中创建新工作簿时,所有单元格的行高和列宽始终相同。 但是,您可以轻松更改一个或多个行和列的高度和宽度。

For new Excel workbooks, the default row height for all the rows is 15, with the default font of Calibri and default font size of 11 points. The default column width for all the columns is 8.38. The default row height for each row depends on the largest font and font size chosen in any of the cells in that row (you can assign different fonts and font sizes for different cells). However, you can choose a specific height for any of the rows as well as a specific column width for any of the columns. The height can be different for different rows and the width different for different columns.

对于新的Excel工作簿,所有行的默认行高为15,默认字体为Calibri,默认字体大小为11点。 所有列的默认列宽为8.38。 每行的默认行高取决于在该行的任何单元格中选择的最大字体和字体大小(您可以为不同的单元格分配不同的字体和字体大小)。 但是,您可以为任何行选择特定的高度,也可以为任何列选择特定的列宽度。 不同行的高度可以不同,不同列的宽度可以不同。

If you want to adjust one row, you can move the cursor over the bottom border of the row heading until it turns into a bar with a double arrow. Then, click on the border and drag it up or down to change the height of the row above the border. As you drag the cursor, the changing height displays in a popup.

如果要调整一行,可以将光标移到行标题的底部边框上,直到变成带有双箭头的条。 然后,单击边框并向上或向下拖动以更改边框上方行的高度。 拖动光标时,变化的高度显示在弹出窗口中。

java excel根据数据自动调整列高 java设置excel列宽_window_03

You can do the same thing to change the width of a column: drag the double-arrow cursor to the left or right on the right border of the column. The width of the column to the left of the border changes width. The width of other columns are not affected.

您可以执行相同的操作来更改列的宽度:将双箭头光标拖动到列右边框的左侧或右侧。 边框左侧列的宽度会更改宽度。 其他列的宽度不受影响。

java excel根据数据自动调整列高 java设置excel列宽_window_04

You can be more exact when specifying the height of one or more rows by entering a specific number for the height. To do this, move your mouse over a row heading until it turns into a right arrow. Then, click on the row heading to select the entire row. If you don’t see the row headings, they might be hidden.

通过输入特定的高度数字来指定一个或多个行的高度时,可以更加精确。 为此,将鼠标移到行标题上方,直到它变成右箭头。 然后,单击行标题以选择整行。 如果您没有看到行标题,则它们可能是隐藏的 。

java excel根据数据自动调整列高 java设置excel列宽_开发工具_05

To select more than one row, click on the first row heading you want to select and drag up or down to select contiguous rows. If the rows you want to select are not contiguous, click the first row heading and then press Ctrl and click on the headings for the other rows you want to select, just like you do to select multiple files in File (or Windows) Explorer.

要选择多个行,请单击要选择的第一行标题,然后向上或向下拖动以选择连续的行。 如果要选择的行不连续,请单击第一个行标题,然后按Ctrl键,然后单击要选择的其他行的标题,就像在File(或Windows)资源管理器中选择多个文件一样。

java excel根据数据自动调整列高 java设置excel列宽_postgresql_06

Either right-click on any selected row or press Shift+F10 on your keyboard. Select “Row Height” from the popup menu.

右键单击任何选定的行,或按键盘上的Shift + F10。 从弹出菜单中选择“行高”。

java excel根据数据自动调整列高 java设置excel列宽_window_07

Enter a new value for the row height for the selected rows on the Row Height dialog box and click “OK”.

在“行高”对话框中为所选行的行高输入新值,然后单击“确定”。

NOTE: You should note what the default, or original, values for row height and column width are before changing them, in case you want to revert back to those values.

注意:在更改它们之前,应注意行高和列宽的默认值或原始值是什么,以防您想恢复到这些值。

java excel根据数据自动调整列高 java设置excel列宽_开发工具_08

You can specify an exact width for one or more columns the same way. Select the columns using the column headings, just like you did for the rows, but drag left or right to select multiple contiguous rows. Then, press Shift+F10 and select “Column Width” from the popup menu.

您可以用相同的方法为一列或多列指定精确宽度。 就像使用行标题一样,使用列标题选择列,但是向左或向右拖动以选择多个连续的行。 然后,按Shift + F10并从弹出菜单中选择“列宽”。

java excel根据数据自动调整列高 java设置excel列宽_vba_09

Enter an exact width for the selected columns on the Column Width dialog box and click “OK”.

在“列宽度”对话框中为所选列输入精确宽度,然后单击“确定”。

java excel根据数据自动调整列高 java设置excel列宽_vba_10

Here’s what our worksheet looks like with the height of the first three rows and the width of the first three columns changed.

这是工作表的样子,前三行的高度和前三列的宽度已更改。

java excel根据数据自动调整列高 java设置excel列宽_开发工具_11

You can change the row height back to the default height, but it many not necessarily be the standard default height. The current default height will be one that fits the largest font and font size used in that row. In other words, the row height of the selected row will be changed to automatically fit the contents of that row.

您可以将行高更改回默认高度,但不一定必须是标准默认高度。 当前的默认高度将适合该行中使用的最大字体和字体大小。 换句话说,将更改所选行的行高以自动适合该行的内容。

To automatically fit the row height, select the rows you want to resize to their default height, make sure the Home tab is active, click “Format” in the Cells section, and then select “AutoFit Row Height” from the Cell Size drop-down menu.

要自动适应行高,请选择要调整其大小为默认高度的行,确保“主页”选项卡处于活动状态,在“单元格”部分中单击“格式”,然后从“单元格大小”下拉菜单中选择“自动调整行高”,下菜单。

To automatically fit one row, you can move the mouse over the bottom border of the desired row heading until it turns into a bar with a double (up and down) arrow, just like when you dragged the border to change the row height. This time, double-click on the border. The row height changes to fit the largest font and font size used in that row.

要自动容纳一行,可以将鼠标移到所需行标题的底部边框上,直到它变成带有双箭头(向上和向下)的条,就像拖动边框以更改行高一样。 这次,双击边框。 行高更改为适合该行中使用的最大字体和字体大小。

java excel根据数据自动调整列高 java设置excel列宽_excel_12

There is also an option to autofit the width of selected columns, but it works slightly differently. The AutoFit Row Height options automatically changes the row height to fit the largest font and font size whether or not there is any content in any cells in that row.

还有一个选项可以自动调整选定列的宽度,但是工作原理略有不同。 无论行中任何单元格中是否有内容,“自动调整行高”选项都会自动更改行高以适合最大字体和字体大小。

When you select one or more columns and then select “AutoFit Column Width” from the “Cell Size” menu in the Cells section of the Home tab, a selected column will only change size if there is content in any cell in that column. Otherwise, if all the cells in the column are empty, the size of that column will not be affected.

当您选择一个或多个列,然后从“主页”选项卡的“单元格”部分的“单元格大小”菜单中选择“自动调整列宽”时,只有当该列中任何单元格中都有内容时,所选列才会更改大小。 否则,如果该列中的所有单元格都为空,则该列的大小将不受影响。

You can also automatically change the width of a column to fit the widest contents in that column by moving the mouse over the border on the desired column heading until it turns into a bar with an double (left and right) arrow, just like when you dragged the border to change the column width. This time, double-click on the border. The column width changes to fit the widest cell contents in that column. This also only works on columns that are not completely empty.

您还可以通过将鼠标移到所需列标题的边框上,直到它变成带有双箭头(向左和向右)的条,自动更改列的宽度以适合该列中最宽的内容。拖动边框以更改列宽。 这次,双击边框。 列宽将更改以适合该列中最宽的单元格内容。 这也仅适用于不完全为空的列。

java excel根据数据自动调整列高 java设置excel列宽_excel_13

Because the default row height is affected by the font and font size assigned to the cells in each row, you cannot specify a value for the default row height. However, the default column width for all the columns in the current worksheet can be changed. To specify a different column width for all the columns in the current worksheet, make sure the Home tab is active, click “Format” in the Cells section, and then select “Default Width” from the Cell Size drop-down menu.

因为默认行高受分配给每一行中单元格的字体和字体大小的影响,所以不能为默认行高指定值。 但是,可以更改当前工作表中所有列的默认列宽。 要为当前工作表中的所有列指定不同的列宽,请确保“主页”选项卡处于活动状态,在“单元格”部分中单击“格式”,然后从“单元格大小”下拉菜单中选择“默认宽度”。

java excel根据数据自动调整列高 java设置excel列宽_开发工具_14

Enter a value for the Standard column width on the Standard width dialog box and click “OK”. The width of all the columns on the current worksheet change to the specified width, no matter how wide the contents are in any of the cells.

在“标准宽度”对话框中输入“标准列”宽度的值,然后单击“确定”。 无论任何单元格中的内容有多宽,当前工作表上所有列的宽度都会更改为指定的宽度。

java excel根据数据自动调整列高 java设置excel列宽_window_15

You can also convert rows into columns and columns into rows, delete blank rows and columns, hide rows and columns, freeze rows and columns, and print the row and column headings in Excel.

您还可以将行转换为行 , 将 列转换为行 , 删除空白行和列 , 隐藏行和列 , 冻结行和列 ,并在Excel中打印行标题和列标题 。

翻译自: https://www.howtogeek.com/270296/how-to-set-row-height-and-column-width-in-excel/

excel设置行高等于列宽