2) Ms. Excel - Importing Exporting Data (By Tahir Aziz)
2) Ms. Excel - Importing Exporting Data (By Tahir Aziz)
By Tahir Aziz
Hands on Course - Ms. Office by Tahir Aziz Ms. Excel: Importing & Exporting Data
Storing the data directly in the Excel workbook has benefit of speedily access of data, direct control and
easy access of data.
However, managing the data being stored in Excel file may put difficulties as file becomes larger in size.
Duplicate copies of Excel file will be created while sharing the data with others which may confuse the
users about the original and updated data.
Many organisations store single copy of data in well managed and secure external sources e.g
databases, online analytical processing (OLAP) cubes, text files etc.
Excel makes it possible to query data lists (tables) stored in external databases to which you have
access and then extract the data that interests you into your worksheet for further manipulation and
analysis. The external data source is connected to the workbook through a data connection, which is a
set of information that describes how to locate, log in, query, and access the external data source. You
can get the data updated by refreshing the connection.
Connection
External Excel
File Workbook
Data Source
Connection information can either be stored in the workbook or in a connection file, such as an Office
Data Connection (ODC) file (.odc).
Data source may have an associated Open Database Connectivity (ODBC) driver or Object Linking and
Embedding Database (OLE DB) provider. The terms ODBC driver and OLE DB connection describe the
interface that connects a database with an application such as an Excel workbook. OLE DB is a more up-
to-date and versatile method than ODBC.
Excel also makes it easy to acquire data from a variety of different data sources, including:
• Microsoft Access database files,
• Web pages on the Internet,
• Text files, and
• Other data sources such as database tables on SQL Servers and Analysis Services,
• XML data files and
• OData Data feeds.
2 IMPORTING DATA
You can import data into Excel workbook from different sources. The common source is text files. Text
file may be of two types i-e
• .txt fields are separated by Tab or sometimes with other characters such as space etc.
• .csv fields are separated by commas.
Data in these files can be opened into Excel file by any of the following methods.
Alternatively, you can go to the folder in which file is placed, right click on file > Open with > select
Excel to open the text file in Excel.
Text import wizard (explained later) will be opened where you can set options to open the data in
Excel worksheet in appropriate format. In this way, original file is opened and no connection is created.
All amendments to the file are updated in the original file.
RISE Premier School of Accountancy Page 3
Hands on Course - Ms. Office by Tahir Aziz Ms. Excel: Importing & Exporting Data
When you make a connection to the source file using Text import wizard, copy of data is created in
your workbook and a connection is developed which can later be refreshed to get updated data from
source file.
Go to Data tab > Get External Data group > From Text
Click here
Step 1 of 3:
• Original data type: If items in the text file are separated by tabs, colons, semicolons, spaces, or
other characters, select Delimited. If all of the items in each column are the same length, select
Fixed width.
• Start import at row: Type or select a row number to specify the first row of the data that you want
to import.
• File origin: Select the character set that is used in the text file. In most cases, you can leave this
setting at its default.
• Preview of file: This box displays the text that will appear when it is separated into columns on the
worksheet.
• Delimiters: Select the character that separates values in your text file. If the character is not listed,
select the Other check box, and then type the character in the box that contains the cursor. These
options are not available if your data type is Fixed width.
• Treat consecutive delimiters as one: Select this check box if your data contains a delimiter of more
than one character between data fields or if your data contains multiple custom delimiters.
• Text qualifier: Select the character that encloses values in your text file. When Excel encounters
the text qualifier character, all of the text that follows that character and precedes the next
occurrence of that character is imported as one value, even if the text contains a delimiter
character.
• Data preview: Review the text in this box to verify that the text will be separated into columns on
the worksheet as you want it.
• Data preview: Set field widths in this section. Click the preview window to set a column break,
which is represented by a vertical line. Double-click a column break to remove it, or drag a column
break to move it.
Step 3 of 3
After you select a data format option for the selected column, the column heading under Data preview
displays the format. If you select Date, select a date format in the Date box.
Choose the data format that closely matches the preview data so that Excel can convert the imported
data correctly.
Final step:
Clicking the Finish button will open the Import Data dialogue box where you can set how and where to
put the data in Excel.
Go to Data tab > Get External Data group > click From Web option. It will open New Web Query
dialogue box.
3 DATA CONNECTIONS
After importing the data into Excel file, a connection is developed between Excel file and the source
file. That connection can be used in future to update the imported data whenever it’s changed in
original source file.
You can find the connections to external data sources by opening the Existing Connections dialogue
box.
Go to Data tab > Get External Data group > Existing Connections
Click here
Click the drop-down arrow against Show in Existing Connections dialogue box to specify which
connections you want to see.
The area below the said menu shows the specified connections.
Workbook connections
You can display all connections in the workbook. For this, go to Data tab > Connections group > click
Connections option. It will open Workbook Connections dialogue box.
The Workbook Connections dialogue box helps you manage one or more connections to external data
sources in your workbook. You can use this dialog box to do the following:
Connection properties
On Workbook Connections dialogue box (shown previously), click Properties to open the Connection
Properties dialogue box. You can also access Connection Properties dialogue box from Data tab >
Connections group > Refresh All menu > Connection Properties
You can use this dialog box to control various settings for connections to external data sources, and to
use, reuse, or switch connection files.
This dialogue box has two tabs Usage and Definition. The settings on the Usage tab control the way
that the connection information is used in the workbook. The settings on the Definition tab control
how the connection information is defined and the source of the connection information, either the
workbook or a connection file.
To keep imported external data up-to-date, you can refresh it to see recent updates and deletes. The
refresh control options are available on Connection Properties dialogue box under Usage tab.
➢ Update all data in the workbook: Go to Data tab, in the Connections group, click Refresh All or
Press CTRL+ALT+F5.
You can access these refresh options from Data tab > Connections group > Connections option >
Workbook Connections dialogue box.
Note: Whenever you refresh a connection manually, Import Text File dialogue box will be opened
where you have to select the source file and click Import. To avoid this step, you can do following:
Open Connection Properties dialogue box (described earlier), on Usage tab under Refresh control
untick the option Prompt for file name on refresh.
Untick this
option
4 EXPORTING DATA
You can export workbook data to text files by saving the workbook as Text or CSV file. These files can
be opened in Ms. Word to further transfer the data to Ms. Word.
Whenever you save a workbook as text file, data of current worksheet is saved only. However, you can
save multiple worksheets one by one with different names. Text files store the data in plain text
therefore many of Excel features like formatting, comments etc. will not be saved in text files.
2) Go to File tab > Save As and select the location where to save the file or press F12 to open the Save
As dialogue box.
3) Change the Save as type to Text (Tab delimited) or CSV (Comma delimited)
Change the
file type
You can export data from Excel worksheet to a Word file by any of following methods.
• Copy data from Excel worksheet and paste into a Word file
or,
• Save Excel worksheet as Text or CSV file (described earlier), then open that file in Word as follows:
Start Ms. Word, go to File tab > Open > Browse and open the saved Text file.
Text file is
opened in Word
Select the data in that file and go Insert tab > Tables group > Table menu > Covert Text to Table.
Adjust the settings on Convert Text to Table dialogue box and click OK.
Raw data will be converted to table (rows and columns) which you can format by applying the built-in
table styles from Table Tools - Design tab.
Select the data range you want to chart, including the column titles and row labels. This range of cells
will be the source data for the chart.
Go to Insert tab > Charts group > click the appropriate chart type to select the chart from associated
menu. You can also click the Recommended Charts option to open the Insert Chart dialogue box and
click the appropriate chart to see its preview in right section. Click OK to insert it.
2: Click here
3: Select appropriate
chart and click OK
1: Select
the data
To see the list of all available charts, click the All Charts tab on Insert Chart dialogue box.
Types of charts
Select the appropriate chart and click OK to insert the chart in worksheet. After selecting the data, you
can use Alt+F1 shortcut key to insert the default chart in the worksheet or press F11 to insert chart on
separate sheet.
Elements of chart
An inserted chart has many elements some of which are displayed by default. You can add further
elements or remove the displayed elements according to your requirement.
You can add or remove following elements to the chart by going to Chart Tools > Design tab > Chart
Layouts group > Add Chart Element menu. You can add/remove following elements to the chart. Each
of these elements has further options which can be accessed by clicking on the element and going to
More… option from sub menu.
• Axes
• Axis titles
• Chart title
• Data labels
• Data table
• Error bars
• Gridlines
• Legend
• Trendline
You can add/remove these elements by clicking the Chart Element icon alongside the chart.
When you insert a chart, two extra tabs under Chart Tools i-e Design and Format tabs appear. These
can be used to modify the design and format of the chart.
Add chart element: The drop-down contains the submenus: Axes, Axis Titles, Chart Title, Data Labels,
Data Table, Error Bars, Gridlines, Legend, Lines, Trendlines and Up/Down Bars.
Quick layout: Change the overall layout of the chart quickly by choosing one of the predefined layout
options.
Data group
Switch row/column: Change the data being displayed on X-axis to be displayed on Y-axis and vice
versa.
Select data: Change the data range included in the chart.
Type group
Location group
Chart Element Selection Box: Select the chart element you want to format from the menu.
Format Selection: Format the selected chart element using the options in the format pane.
Reset to Match Style: Clear any custom formatting from the selected element to ensure that the
formatting matches the overall theme of the workbook.
Shapes Gallery: A gallery containing the recently inserted or used shapes. The drop-down contains the
groups: Recently Used Shapes, Lines, Rectangles, Basic Shapes, Block Arrows, Equation Shapes,
Flowchart, Stars and Banners and Callouts.
Change Shape: Change the shape of the drawing, preserving all the formatting.
Shape Styles Gallery: Quickly add a visual style to the selected shape or line.
Shape Fill: Fill the selected shape with a solid colour, gradient, picture or texture.
Shape Outline: Change the color, weight, or style of the selected chart element.
Shape Effects: Apply special visual effects to the chart element, such as shadows, bevels, or 3-D
WordArt Styles
WordArt Styles: Apply predefined text styles to the all or selected elements.
Text Fill: Fill the text with a solid colour, gradient, picture or texture.
Text Outline: Customise the outline of your text by choosing the colour, width and line style.
Text Effects: Add a visual effect such as shadow, glow or reflection to your text.
Arrange Group
Size Group