Which of the following AutoFit options adjust column widths to fit the contents of the table?

How to Apply Different AutoFit Settings to a Table

When creating a table using a visual agent such as Microsoft Word, you will often find yourself using one of the AutoFit options to automatically size the table to the desired width. For instance you can use the AutoFit to Window option to fit the table to the width of the page and the AutoFit to Contents option to allow each cell to grow or shrink to accommodate its contents.

By default Aspose.Words inserts a new table using “AutoFit to Window”. The table will size to the available width on the page. To change the sizing behavior on such a table or an existing table you can call Table.autoFit(int) method. This method accepts an AutoFitBehavior enumeration which defines what type of auto fitting is applied to the table.

As in Microsoft Word, an autofit method is actually a shortcut which applies different properties to the table all at once. These properties are actually what give the table the observed behavior. We will discuss these properties for each autofit option. We will use the following table and apply the different auto fit settings as a demonstration:

Which of the following AutoFit options adjust column widths to fit the contents of the table?

AutoFitting a Table to Window

The following code example autofits a table to fit the page width.

The result after this operation is a table which is lengthened to fit the width of the page is shown below.

Which of the following AutoFit options adjust column widths to fit the contents of the table?

AutoFitting a Table to Contents

The following code example autofits a table in the document to its contents.

The result of the above code causes the table to automatically resize each column to its contents.

Which of the following AutoFit options adjust column widths to fit the contents of the table?

When a table is an auto fitted to contents the following steps are actually undertaken behind the scenes:

  1. The Table.AllowAutoFit property is enabled to automatically resize each cell to accommodate its contents.
  2. The table-wide preferred width under Table.PreferredWidth is removed.
  3. The CellFormat.PreferredWidth is removed for every cell in the table.
  4. The column widths are recalculated for the current content in the table. The end result is a table whose column widths and the entire table width change automatically to best accommodate the content as the user edits text in MS Word.

Disabling AutoFitting on a Table and Use Fixed Column Widths

The following code example disables autofitting and enables fixed widths for the specified table.

The result of disabling autofit and using fixed widths for the column sizes is shown below.

Which of the following AutoFit options adjust column widths to fit the contents of the table?

When a table has auto fit disabled and fixed column widths used instead the following steps are taken:

  1. The Table.AllowAutoFit property is disabled so columns do not grow or shrink to their contents.
  2. The table-wide preferred width is removed from the Table.PreferredWidth.
  3. The CellFormat.PreferredWidth is removed from all cells in the table. The end result is a table whose column widths are defined using the CellFormat.getWidth() property and whose columns do not automatically resize when the user enter texts or the page size is modified.

Lesson 6: Modifying Columns, Rows, and Cells

/en/excel2016/cell-basics/content/

Introduction

By default, every row and column of a new workbook is set to the same height and width. Excel allows you to modify column width and row height in different ways, including wrapping text and merging cells.

Optional: Download our practice workbook.

Watch the video below to learn more about modifying columns, rows, and cells.

To modify column width:

In our example below, column C is too narrow to display all of the content in these cells. We can make all of this content visible by changing the width of column C.

  1. Position the mouse over the column line in the column heading so the cursor becomes a double arrow.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

  2. Click and drag the mouse to increase or decrease the column width.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

  3. Release the mouse. The column width will be changed.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

With numerical data, the cell will display pound signs (#######) if the column is too narrow. Simply increase the column width to make the data visible.

To AutoFit column width:

The AutoFit feature will allow you to set a column's width to fit its content automatically.

  1. Position the mouse over the column line in the column headingso the cursor becomes a double arrow.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

  2. Double-click the mouse. The column width will be changed automatically to fit the content.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

You can also AutoFit the width for several columns at the same time. Simply select the columns you want to AutoFit, then select the AutoFit Column Width command from the Format drop-down menu on the Home tab. This method can also be used for row height.

Which of the following AutoFit options adjust column widths to fit the contents of the table?

To modify row height:

  1. Position the cursor over the row line so the cursor becomes a double arrow.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

  2. Click and drag the mouse to increase or decrease the row height.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

  3. Release the mouse. The height of the selected row will be changed.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

To modify all rows or columns:

Instead of resizing rows and columns individually, you can modify the height and width of every row and column at the same time. This method allows you to set a uniform size for every row and column in your worksheet. In our example, we will set a uniform row height.

  1. Locate and click the Select All button just below the name box to select every cell in the worksheet.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

  2. Position the mouse over a row line so the cursor becomes a double arrow.
  3. Click and drag the mouse to increase or decrease the row height, then release the mouse when you are satisfied. The row height will be changed for the entire worksheet.

    Which of the following AutoFit options adjust column widths to fit the contents of the table?

      Inserting, deleting, moving, and hiding

      After you've been working with a workbook for a while, you may find that you want to insert new columns or rows, delete certain rows or columns, move them to a different location in the worksheet, or even hide them.

      To insert rows:

      1. Select the row heading below where you want the new row to appear. In this example, we want to insert a row between rows 4 and 5, so we'll select row 5.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      2. Click the Insert command on the Home tab.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. The new row will appear above the selected row.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      When inserting new rows, columns, or cells, you will see a paintbrush icon next to the inserted cells. This button allows you to choose how Excel formats these cells. By default, Excel formats inserted rows with the same formatting as the cells in the row above. To access more options, hover your mouse over the icon, then click the drop-down arrow.

      Which of the following AutoFit options adjust column widths to fit the contents of the table?

      To insert columns:

      1. Select the column heading to the right of where you want the new column to appear. For example, if you want to insert a column between columns D and E, select column E.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      2. Click the Insert command on the Home tab.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. The new column will appear to the left of the selected column.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      When inserting rows and columns, make sure you select the entire row or column by clicking the heading. If you select only a cell in the row or column, the Insert command will only insert a new cell.

      To delete a row or column:

      It's easy to delete a row or column that you no longer need. In our example we'll delete a row, but you can delete a column the same way.

      1. Select the row you want to delete. In our example, we'll select row 9.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      2. Click the Delete command on the Home tab.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. The selected row will be deleted, and those around it will shift. In our example, row 10 has moved up, so it's now row 9.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      It's important to understand the difference between deleting a row or column and simply clearing its contents. If you want to remove the content from a row or column without causing others to shift, right-click a heading, then select Clear Contents from the drop-down menu.

      Which of the following AutoFit options adjust column widths to fit the contents of the table?

      To move a row or column:

      Sometimes you may want to move a column or row to rearrange the content of your worksheet. In our example we'll move a column, but you can move a row in the same way.

      1. Select the desired column heading for the column you want to move.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      2. Click the Cut command on the Home tab, or press Ctrl+X on your keyboard.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. Select the column heading to the right of where you want to move the column. For example, if you want to move a column between columns E and F, select column F.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      4. Click the Insert command on the Home tab, then select Insert Cut Cells from the drop-down menu.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      5. The column will be moved to the selected location, and the columns around it will shift.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      You can also access the Cut and Insert commands by right-clicking the mouse and selecting the desired commands from the drop-down menu.

      Which of the following AutoFit options adjust column widths to fit the contents of the table?

      To hide and unhide a row or column:

      At times, you may want to compare certain rows or columns without changing the organization of your worksheet. To do this, Excel allows you to hide rows and columns as needed. In our example we'll hide a few columns, but you can hide rows in the same way.

      1. Select the columns you want to hide, right-click the mouse, then select Hide from the formatting menu. In our example, we'll hide columns C, D, and E.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      2. The columns will be hidden. The green column line indicates the location of the hidden columns.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. To unhide the columns, select the columns on both sides of the hidden columns. In our example, we'll select columns B and F. Then right-click the mouse and select Unhide from the formatting menu.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      4. The hidden columns will reappear.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      Wrapping text and merging cells

      Whenever you have too much cell content to be displayed in a single cell, you may decide to wrap the text or merge the cell rather than resize a column. Wrapping the text will automatically modify a cell's row height, allowing cell contents to be displayed on multiple lines. Merging allows you to combine a cell with adjacent empty cells to create one large cell.

      To wrap text in cells:

      1. Select the cells you want to wrap. In this example, we'll select the cells in column C.
      2. Click the Wrap Text command on the Home tab.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. The text in the selected cells will be wrapped.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      Click the Wrap Text command again to unwrap the text.

      To merge cells using the Merge & Center command:

      1. Select the cell range you want to merge. In our example, we'll select A1:F1.
      2. Click the Merge & Center command on the Home tab. In our example, we'll select the cell range A1:F1.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. The selected cells will be merged, and the text will be centered.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      To access more merge options:

      If you click the drop-down arrow next to the Merge & Center command on the Home tab, the Merge drop-down menu will appear.

      Which of the following AutoFit options adjust column widths to fit the contents of the table?

      From here, you can choose to:

      • Merge & Center: merges the selected cells into one cell and centers the text
      • Merge Across: merges the selected cells into larger cells while keeping each row separate
      • Merge Cells: merges the selected cells into one cell but does not center the text
      • Unmerge Cells: unmerges selected cells

      You'll want to be careful when using this feature. If you merge multiple cells that all contain data, Excel will keep only the contents of the upper-left cell and discard everything else.

      To center across selection:

      Merging can be useful for organizing your data, but it can also create problems later on. For example, it can be difficult to move, copy, and paste content from merged cells. A good alternative to merging is Center Across Selection, which creates a similar effect without actually combining cells.

      Watch the video below to learn why you should use Center Across Selection instead of merging cells.

      1. Select the desired cell range. In our example, we'll select A1:F1. Note: If you already merged these cells, you should unmerge them before continuing to step 2.
      2. Click the small arrow in the lower-right corner of the Alignment group on the Home tab.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      3. A dialog box will appear. Locate and select the Horizontal drop-down menu, select Center Across Selection, then click OK.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

      4. The content will be centered across the selected cell range. As you can see, this creates the same visual result as merging and centering, but it preserves each cell within A1:F1.

        Which of the following AutoFit options adjust column widths to fit the contents of the table?

        Challenge!

        1. Open our practice workbook.
        2. Autofit Column Width for the entire workbook.
        3. Modify the row height for rows 3 to 14 to 22.5 (30 pixels).
        4. Delete row 10.
        5. Insert a column to the left of column C. Type SECONDARY CONTACT in cell C2.
        6. Make sure cell C2 is still selected and choose Wrap Text.
        7. Merge and Center cells A1:F1.
        8. Hide the Billing Address and Phone columns.
        9. When you're finished, your workbook should look something like this:

          Which of the following AutoFit options adjust column widths to fit the contents of the table?

        /en/excel2016/formatting-cells/content/

        How do you AutoFit the width of a column?

        Change the column width to automatically fit the contents (AutoFit) Select the column or columns that you want to change. On the Home tab, in the Cells group, click Format. Under Cell Size, click AutoFit Column Width.

        How do you adjust the tables columns to fit the text in Word?

        To adjust table row and column size in Word: Click anywhere in the table. In "Table Tools" click the [Layout] tab > locate the "Cell Size" group and choose from of the following options: To fit the columns to the text (or page margins if cells are empty), click [AutoFit] > select "AutoFit Contents."

        Where is AutoFit on word?

        To use the feature, follow these steps:.
        Select the entire table..
        Make sure the Layout tab of the ribbon is displayed..
        In the Cell Size group click AutoFit. Word displays a drop-down list of choices..
        Choose AutoFit Contents from the choices..