<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="https://sampathblogs.online/wp-content/plugins/rss-feed-styles/public/template.xsl"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:rssFeedStyles="http://www.lerougeliet.com/ns/rssFeedStyles#"
>

<channel>
	<title>study &#8211; Sampath Kumar A</title>
	<atom:link href="https://sampathblogs.online/category/study/feed/" rel="self" type="application/rss+xml" />
	<link>https://sampathblogs.online</link>
	<description>Be Concious Be More</description>
	<lastBuildDate>Wed, 25 Mar 2020 14:10:10 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<rssFeedStyles:reader name="Digg Reader" url="http://digg.com/reader/search/https%3A%2F%2Fsampathblogs.online%2Ffeed%2F"/><rssFeedStyles:reader name="Feedly" url="http://cloud.feedly.com/#subscription%2Ffeed%2Fhttps://sampathblogs.online/feed/"/><rssFeedStyles:button name="Like" url="https://www.facebook.com/sharer/sharer.php?u=%url%"/><rssFeedStyles:button name="G+" url="https://plus.google.com/share?url=%url%"/><rssFeedStyles:button name="Tweet" url="https://twitter.com/intent/tweet?url=%url%"/><rssFeedStyles:button name="Pinterest" url="https://www.pinterest.com/pin/create/button?url=%url%"/><rssFeedStyles:button name="LinkedIn" url="https://www.linkedin.com/cws/share?url=%url%"/>	<item>
		<title>Microsoft IME : A Brief Overview</title>
		<link>https://sampathblogs.online/2020/03/microsoft-ime-basics/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-ime-basics</link>
					<comments>https://sampathblogs.online/2020/03/microsoft-ime-basics/#respond</comments>
		
		<dc:creator><![CDATA[mail2sampath]]></dc:creator>
		<pubDate>Wed, 25 Mar 2020 14:05:37 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[Basic guide]]></category>
		<category><![CDATA[Japan]]></category>
		<guid isPermaLink="false">http://excelall.byethost32.com/?p=1066</guid>

					<description><![CDATA[We have been using this handy thing called the IME on Windows OS that does some magic to allow us to type pretty easily in Japanese. This is actually a little freebie that has been thrown into Windows. It is... <a class="more-link" href="https://sampathblogs.online/2020/03/microsoft-ime-basics/">Continue Reading &#8594;</a>]]></description>
										<content:encoded><![CDATA[<p>We have been using this handy thing called the IME on Windows OS that does some magic to allow us to type pretty easily in Japanese. This is actually a little freebie that has been thrown into Windows. It is quite simple to set up and use. Though we may be using IME since a long time we may not be knowing the proper way to use the various options available. Here i would like to highlight the various features.</p>
<h5><strong>Input Modes</strong></h5>
<p>To start with, you can open up notepad (or your favorite word processing app and give it a try).&nbsp; To access notepad, you can simply type notepad in the search window of the start menu and press Enter.</p>
<p>Now, you can see that your IME has switched to <strong>Half-width alphanumeric</strong> by default and displayed as &#8216;A&#8217; in the IME bar. When it is in this mode, you can type in English like a regular keyboard. If you switch to <strong>Hiragana </strong>mode, by clicking on the ‘A’ in the IME bar and selecting <strong>Hiragana</strong>, you can type in Japanese.</p>
<div id="attachment_1303" style="width: 257px" class="wp-caption alignright"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-1303" class="size-medium wp-image-1303" src="https://sampathblogs.online/wp-content/uploads/2020/01/ime-247x300.jpg" alt="" width="247" height="300" srcset="https://sampathblogs.online/wp-content/uploads/2020/01/ime-247x300.jpg 247w, https://sampathblogs.online/wp-content/uploads/2020/01/ime.jpg 314w" sizes="(max-width: 247px) 100vw, 247px" /><p id="caption-attachment-1303" class="wp-caption-text">IME Option</p></div>
<p>In hiragana mode, you’ll see romaji/english letters on the screen until you make a proper japanese word or letter.&nbsp; For example, if you type hjkly, it’ll show up as romaji.&nbsp; You must type a valid japanese word/kana and then it will automatically switch to the kana.&nbsp; So if you type the letters konnichiha, you’ll get こんにちは.&nbsp; Now if you hit enter, it will simply leave the kana as is.&nbsp; If you want to use the kanji, you have to hit the space bar.&nbsp; This will give you the IME’s best guess as to what kanji you want to use.&nbsp; If you hit the space bar again, you will see a pop up menu where you can select the kanji that you want to use.</p>
<p>Note, this is also the way you can get katakana without having to select it in the IME. Some kana have several kanji available for them. If the kanji or often confused (they have similar meanings, same pronunciation, but different kanji) then there are notes available to help you differentiate. Unfortunately these notes are in Japanese only.</p>
<p><strong>Half-width Katakana</strong> characters are displayed at half their normal width (a 1:2 aspect ratio), instead of the usual square (1:1) aspect ratio. For example, the usual <strong>Full-width</strong> form of the katakana ka is カ while the half-width form is ｶ. You can also convert to katakana (full/half-width) characters when entering a reading in Hiragana input mode. Press the SPACE key after you enter a reading, and then select the appropriate katakana from the options list.</p>
<p>Half-width characters were used in the early days of Japanese computing. However, these Half-width characters are not generally used today, but find some use in specific settings, such as cash register displays, on shop receipts, bank book, web based forms, Japanese digital television etc., Half-width characters are typically English/Roman (romaji) characters and numbers. You are often required to enter phone numbers and email addresses in half -width on web application forms. Do note that some forms require your address and postal code in <strong>Full-width Alphanumeric</strong>, including all the numbers. In either the Full-width or Half-width Alphanumeric mode, enter the alphanumeric text, and then press the F9 key to convert to Full-width Alphanumeric characters or the F10 key to convert to Half-width Alphanumeric characters.</p>
<p>Two shortcuts that will definitely come in handy are the keyboard to switch between languages (SHIFT+ALT) and the shortcut to switch between alphanumeric and hiragana (ALT+`).&nbsp;Microsoft IME will remember what you are using in what window. So, for example, if you are typing in Japanese in Wordpad, you should be able to switch to Firefox and type in English without changing it in the IME.</p>
<h5><strong>Advanced Features</strong></h5>
<ul>
<li><strong>Use special characters</strong><br />
Having an IME makes it much easier to use the special characters&nbsp;like <em>arrows, stars, hearts, shapes</em> and more, that are available on most computers nowadays. While these characters don’t always display properly on every computer and in every software environment, they are becoming more usable all the time and are particularly well supported in Japan. To type a special character, you simply need to know the <em>keyword</em> that will call it up in your IME. Examples are kigou 記号, suuji 数字, hoshi 星, yajirushi 矢印, maru 丸, ongaku 音楽,&nbsp;kakko 括弧 etc.,</li>
<li><strong>Register custom words</strong><br />
The IME has some built in functionality for detecting which conversions you use most and prioritizing them, and detecting non-standard conversions you use and automating them. However, there may be cases where it would be easier to just add a certain word to your IME’s dictionary. In the above figure &#8220;IME Options&#8221; select the <em><strong>Add Word </strong></em>option and enter the required information like the kanji to be displayed, reading of the kanji, user comments if any and part of speech(Noun/Place name/shortcut etc.,) in the respective boxes to add it to the dictionary.</li>
<li><strong>Mini hiragana characters</strong><br />
The hiragana characters あいうえおやゆよつ and corresponding katakana アイウエオヤユヨツ can all be sized down at will to meet your needs. Simply prefix the sound as you would type it normally with an <strong>L or l</strong> (for “little”). For example,<em> L + U = ぅ</em>. This only works with the vowel characters, <em>ya/yu/yo</em> &amp; <em>tsu </em>and are the only ones used in down sized form in japanese<em>.</em></li>
<li><strong>Reconverting</strong><br />
In case you are proof-reading an email or something you wrote in Japanese and notice you accidentally entered the wrong kanji for a word and want to change it. There are two ways to correct the word to the right kanji, one is delete and retype it and the other method is to reconvert it. Select the word you want to change, right click and choose “Reconversion” which will display the kanji list to choose from. Reconverting via right-click isn’t possible in all settings.&nbsp; If your IME is on but you don’t get the reconvert option, try copying the text into a different application.</li>
<li><strong>Excel IME</strong><br />
We already know that,&nbsp;Microsoft IME will remember what you are using in what window. But for people who use excel frequently in data entry, they may need to change the IME setting each time they move to a new cell/column in a sheet. In order to overcome this, Excel has an inbuilt provision for IME ,i.e, navigate to <em>Data &gt; Data Validation &gt; IME Mode</em> tab and select the appropriate mode for each column or cell beforehand and see that the input mode changes automatically as you move to the respective cell/column.</li>
</ul>
<div id="attachment_1288" style="width: 758px" class="wp-caption aligncenter"><img decoding="async" aria-describedby="caption-attachment-1288" class="wp-image-1288 size-full" src="https://sampathblogs.online/wp-content/uploads/2020/01/excel.jpg" alt="" width="748" height="487" srcset="https://sampathblogs.online/wp-content/uploads/2020/01/excel.jpg 748w, https://sampathblogs.online/wp-content/uploads/2020/01/excel-300x195.jpg 300w, https://sampathblogs.online/wp-content/uploads/2020/01/excel-600x391.jpg 600w" sizes="(max-width: 748px) 100vw, 748px" /><p id="caption-attachment-1288" class="wp-caption-text">Excel inbuilt IME Option</p></div>
<h5><strong>Repair IME</strong></h5>
<p>Sometimes you might face issues related to IME like kanji conversions are not happening or proper kanjis are not showing up during conversions. In such cases we can use the &#8220;Repair dictionaries&#8221; option. Navigate to <em>Properties</em> &gt; &#8220;<em>Advanced</em>&#8221; button &gt; Dictionary/Auto-tuning tab &#8211; &#8220;<em>Repair dictionaries</em>&#8221; button, now the &#8220;Microsoft IME Dictionary Repair&#8221; window will pop up wherein we need to click on &#8220;Yes&#8221; to start the repair. Once the repair is completed, another pop up will show that the repair operation is completed. Now cross check whether the IME issue is rectified or not.</p>
<p>If you enjoyed this article, please consider sharing it!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sampathblogs.online/2020/03/microsoft-ime-basics/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Working on MS Excel using Python OpenPyXL Library</title>
		<link>https://sampathblogs.online/2019/09/working-on-ms-excel-using-python-openpyxl-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-on-ms-excel-using-python-openpyxl-library</link>
					<comments>https://sampathblogs.online/2019/09/working-on-ms-excel-using-python-openpyxl-library/#respond</comments>
		
		<dc:creator><![CDATA[mail2sampath]]></dc:creator>
		<pubDate>Wed, 25 Sep 2019 13:52:29 +0000</pubDate>
				<category><![CDATA[study]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Data Analysis]]></category>
		<guid isPermaLink="false">http://excelall.byethost32.com/?p=1097</guid>

					<description><![CDATA[Openpyxl is a Python library to read/write Excel xlsx/xlsm/xltx/xltm files. This can be particularly helpful in data analysis wherein, user might have to go through thousands of rows and pick out few handful information to make small changes based on... <a class="more-link" href="https://sampathblogs.online/2019/09/working-on-ms-excel-using-python-openpyxl-library/">Continue Reading &#8594;</a>]]></description>
										<content:encoded><![CDATA[<p>Openpyxl is a Python library to read/write Excel xlsx/xlsm/xltx/xltm files. This can be particularly helpful in data analysis wherein, user might have to go through thousands of rows and pick out few handful information to make small changes based on some criteria. Using Openpyxl module, these tasks can be done very efficiently and easily.</p>
<p>Since python is the language being used, one needs to have the python installer downloaded and installed as mentioned in one my earlier <a href="https://sampathblogs.online/index.php/2018/07/22/data-analysis-using-python/">blogs</a>. The next step is to install the library &#8216;openpyxl&#8217; using the following command in the command prompt.</p>
<p><code class="EnlighterJSRAW" data-enlighter-language="no-highlight">C:\Users\foldername&gt;pip install openpyxl</code></p>
<p>Depending upon whether the library is already installed or is a new install, appropriate message will be displayed. Once this is done, just type in the following command to verify the proper install.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">C:\Users\foldername&gt;py
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt;import openpyxl
&gt;&gt;&gt;</pre>
<p>The above status verifies that the openpyxl library is properly installed and can be imported to be used in the python programs. The final requirement would be to install the MS Excel program since we are mainly using python programs to work with excel data. Openoffice can be used as well in place of MS Excel.</p>
<p>IDLE is the Python environment(Editor &amp; Shell) we will be using. You can open IDLE directly from your Python script file. Right click the file, then choose &#8220;Edit with IDLE&#8221;. You can run your python script by going to &#8220;Run &#8211;&gt; Run Module&#8221; or simply by hitting F5. The script will then run in the IDLE shell window. Since you now have a saved script, you can run it again and again.</p>
<h3><strong>Description</strong></h3>
<h4>Workbooks, Sheets and Cells</h4>
<p>In our first python script below, we will look into the basic excel operations performed on a file like <strong>opening an existing workbook, creating/copying/appending/deleting a sheet in the workbook, doing the &#8216;save as&#8217; on workbooks</strong> etc. Please refer to the below code wherein the comments have been added at appropriate places describing the actions they perform. Also the section of code has been commented out just to execute it part by part.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from openpyxl import Workbook        # Module needed for creating new workbook
from openpyxl import load_workbook   # Module needed for loading existing workbook
from copy import copy                # Module needed for copying sheet

wb=Workbook()
filename = "test workbook.xlsx"

wb = load_workbook(filename)         #open existing workbook
sheet = wb.active
sheet['A1']=1                        #Absolute cell referencing
sheet.cell(row=2,column=2).value=2   #Relative cell referencing

##sheet1=wb.create_sheet("sheet1")   #create and append a new sheet at the end,
##sheetx=wb.create_sheet("sheetx",0) #desired position

##wb.remove(wb["sheetx"])            #delete a sheet,
##del wb["sheet1"]                   #alternate way of deleting sheet

##sheet.title = "sampath"            #assign a new name/title to a sheet

##print(sheet.title)                 #print the sheet name/title

##source = wb["sampath"]             #copy and create a new sheet "sheetcpy"
##new_sheet = wb.copy_worksheet(source)
##new_sheet.title = "sheetcpy"

##worksheets = wb.sheetnames         #indexing &amp; printing all sheet names
##print(worksheets)

##wb.save("new workbk.xlsx")         #save the workbook with a new name

wb.save(filename)                    # save the above data
</pre>
<p>In our next python script below, we move into working on cells. Here we are mainly focusing on <strong>assigning value to a cell, creating cell range, looping/iterating over multiple rows/columns, appending row values, inserting/deleting row/s at the desired location, inserting/deleting column/s at the desired location, moving a cell/range of cells to a desired location, copying a cell value to the desired location</strong> etc. Comments have been added in the code at appropriate places for better understanding.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from openpyxl import Workbook                   # Module needed for creating new workbook
from openpyxl import load_workbook              # Module needed for loading existing workbook

from openpyxl.utils.cell import get_column_letter       # Module to get column letter
from openpyxl.utils.cell import column_index_from_string# Module to get column index#

wb=Workbook()
filename = "testbook.xlsx"

wb = load_workbook(filename)
sheet = wb.active

##sheet[get_column_letter(5)+"2"].value = "abc"         #using get column letter on cell
##print(sheet["E2"].value)

##cell_range = sheet['A1':'B2']                         #create cell range with absolute ref
##cell_range = sheet[get_column_letter(1)+"1":get_column_letter(2)+"2"]  #relative ref
##for a, b in cell_range:
##    print(a.value, b.value)
##print()

##print(column_index_from_string("A"))                  #using get column index

##sheet["A1"].value = "sampath"                         #using offset on cell
##sheet.cell(1,1).offset(0,1).value = "kumar"
##sheet["A1"].offset(0,2).value = "ananda"
##print(sheet["A1"].value,sheet["B1"].value,sheet["C1"].value)

##for i in range(1, 4):                                 #loop over row/col and print coordinates
##    for j in range(1, 4):
##        cell = sheet.cell(row=i, column=j)
##        print(cell.coordinate, end=" ")
##    print()

##for row in sheet.iter_rows(max_row=5, max_col=5):     #iterate using iter_rows
##        for cell in row:  
##            print(cell.coordinate, end=" ")
##        print()

##for column in sheet.iter_cols(max_col=5, max_row=5):  #iterate using iter_cols
##        for cell in column:  
##            print(cell.coordinate, end=" ")
##        print()

##sheet.append( ["abc", 123, 456] )                     #append row values

##sheet.insert_rows(0)                                  #insert row at the desired loc                                   
##sheet.delete_rows(1)                                  #delete row/s from desired loc&gt;0
##sheet.delete_rows(2,3)                                     

##sheet.insert_cols(0)                                  #insert col at the desired loc                               
##sheet.delete_cols(1)                                  #insert col/s at the desired loc
##sheet.delete_cols(1,3)

##sheet.move_range("A1:B2",rows=5,cols=0)               #moving range of cells
##sheet._move_cell(7,1,25,0)                            #moving a cell

##oldcell = sheet.cell(1,5)                             #copy a cell value
##newcell = sheet.cell(10,10,oldcell.value)
##newcell = sheet.cell(25,oldcell.col_idx,oldcell.value)

wb.save(filename)                                       #save the above data</pre>
<p>In our final script in this section, we will be dealing with mainly the cell formatting operations like, <strong>cell border/colour/number formatting, cell format copy, merge/unmerge cells, cell/sheet protection, creating a workbook with fixed number of sheets</strong>.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from openpyxl import Workbook                   # Module needed for creating new workbook
from openpyxl import load_workbook              # Module needed for loading existing workbook

from openpyxl.styles.borders import Border, Side, BORDER_THIN, BORDER_THICK, BORDER_DASHDOT, BORDER_DOUBLE  
                                                         #border format

from openpyxl.styles import colors, Font                 # Module needed for colour formatting
from openpyxl.styles.fills import PatternFill

from openpyxl.styles.numbers import FORMAT_PERCENTAGE_00 # Module needed for number formatting

from openpyxl.styles.protection import Protection        # Module needed for cell/sheet protection

from copy import copy                                    # Module needed for copy operation

wb=Workbook()
filename = "testcellfmt.xlsx"

wb = load_workbook(filename)
sheet = wb.active

##border_cell = sheet.cell(row=3, column=4)
##new_cell = sheet.cell(row=5, column=2)
##                                                              #cell border format        
##borders = Border(left=Side(border_style=BORDER_THIN, color='00000000'),\
##                 right=Side(border_style=BORDER_THICK, color='00000000'),\
##                 top=Side(border_style=BORDER_DASHDOT, color='00000000'),\
##                 bottom=Side(border_style=BORDER_DOUBLE, color='00000000'))
##border_cell.border = borders                                            
##
##red_color = colors.Color(rgb='00FF0000')                      #cell colour fill  
##solid_red_fill = PatternFill(patternType='solid', fgColor=red_color)
##border_cell.fill = solid_red_fill

##border_cell.number_format = FORMAT_PERCENTAGE_00              #cell number - format to %age

##new_cell.border = copy(border_cell.border)                    #cell format copy 
##new_cell.fill = copy(border_cell.fill)

##sheet.merge_cells('A1:B1')                                    #merge/unmerge cells
##sheet.unmerge_cells('A1:B1')
##sheet.merge_cells(start_row=3, start_column=1, end_row=3, end_column=3)

##sheet.protection.sheet = True                                 #sheet protection
##sheet.protection.password = '123'
##sheet.protection.enable()

##sheet.cell(row=1,column=1).protection = Protection(locked=False, hidden=False)  #unlock a cell in the sheet

##wb2 = Workbook()                                              #creation of workbook with fixed # of sheets
##wb2.security.workbookPassword = '123'
##wb2.security.lockStructure = True
##wb2.save("Cell formatting2.xlsx")

wb.save(filename)                                               #save the above data</pre>
<h4>Formulas, Tables and Other formatting</h4>
<p>Moving forward into the topic of <strong>formula and table</strong> in the below strip of code,  we are creating a table with three columns and five rows with values assigned to each cell as part of the code. The sum of the values in the first column is calculated using the SUM formula and the result is assigned to the first column in the seventh row.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from openpyxl import Workbook                 # Module needed for creating new workbook
from openpyxl import load_workbook            # Module needed for loading existing workbook

from openpyxl.worksheet.table import Table, TableStyleInfo # Module needed for Table operations

wb=Workbook()
filename = "testbooktable.xlsx"

wb = load_workbook(filename)
sheet = wb.active
                                                                     #TABLE creation
sheet.append(["QtyA","QtyB","QtyC"])                                 #Heading must be string
cell_range = sheet['A2':'C6']
for a, b, c in cell_range:
    a.value =5
    b.value =2
    c.value =5
table_name = Table(displayName="tablename", ref="A1:C6")
style = TableStyleInfo(name="TableStyleMedium8", showRowStripes=True)#Add a default style
table_name.tableStyleInfo = style
sheet.add_table(table_name)                                          #Add table to the sheet

first_cell = sheet.cell(2,1)                                         #SUM formula 
last_cell = sheet.cell(6,1)
sheet.cell(7,1).value = "=sum(" +str(first_cell.coordinate) +":" +str(last_cell.coordinate) +")"

wb.save(filename)                                                    #save the above data
</pre>
<div id="attachment_1378" style="width: 255px" class="wp-caption aligncenter"><img decoding="async" aria-describedby="caption-attachment-1378" class="wp-image-1378 size-full" src="https://sampathblogs.online/wp-content/uploads/2020/01/table.jpg" alt="" width="245" height="150" /><p id="caption-attachment-1378" class="wp-caption-text">Table &amp; Formula Excel Output</p></div>
<p>Here we can see the actual output of the above code in Excel file. We can observe that all the cells have been assigned values and the SUM of the first column is appropriately placed in the seventh row of the first column.</p>
<p>Next i would like to move onto the other formatting options available in excel and how do we realize the same in python code. The formatting options that we will be looking into are <strong>Auto filter, Freeze row/column, Grouping/Ungrouping of rows/columns, print page setup</strong>. In the code i have also shown how to open an excel file directly after executing the code. Please refer to the comments in the below code for details.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from openpyxl import Workbook                 # Module needed for creating new workbook
from openpyxl import load_workbook            # Module needed for loading existing workbook

from openpyxl.worksheet.page import PrintPageSetup  # Module needed for print pagesetup

import os                                     # Module needed to open excel file after code run

wb=Workbook()
filename = "testexcelf.xlsx"

wb = load_workbook(filename)
sheet = wb.active

sheet["A1"].value = "Month"                                    #offset on cell to assign headr
sheet.cell(1,1).offset(0,1).value = "Serial"
sheet.auto_filter.ref = "A1:B15"                               #auto filter/manually click OK
sheet.auto_filter.add_filter_column(0, ["Jan", "Feb", "Mar"])  
sheet.auto_filter.add_sort_condition("B2:B15", descending=True)#auto filter/man. click option
##sheet.freeze_panes = "A2"                                    #freeze row1
##sheet.freeze_panes = "A1"                                    #unfreeze "A1"/None
##sheet.freeze_panes = "B1"                                    #freeze column1

##sheet.column_dimensions.group('A','D')                       #column grouping A to D
##sheet.column_dimensions.group('A','D', outline_level =2)     #Level 2 grouping
##sheet.column_dimensions.group('C','D', outline_level =1)     #Level 1 group within Level 2
##sheet.row_dimensions.group(1,10)                             #row grouping 1 to 10 rows
                                                               #*ungrouping tbd manually*

                                                               #print page setup
##sheet.page_setup = PrintPageSetup(worksheet=None, orientation='portrait', paperSize=sheet.PAPERSIZE_LETTER,\
##      scale=None, fitToHeight=None, fitToWidth=None, firstPageNumber=None,\
##      useFirstPageNumber=None, paperHeight=None, paperWidth=None, pageOrder=None,\
##      usePrinterDefaults=None, blackAndWhite=None, draft=None, cellComments=None,\
##      errors=None, horizontalDpi=None, verticalDpi=None, copies=None, id=None)

os.system("start EXCEL.EXE " + filename)                       #opening the excel sheet 

wb.save(filename)                                              #save the above data</pre>
<div id="attachment_1292" style="width: 490px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1292" class="wp-image-1292 size-full" src="https://sampathblogs.online/wp-content/uploads/2020/01/filter.jpg" alt="" width="480" height="488" srcset="https://sampathblogs.online/wp-content/uploads/2020/01/filter.jpg 480w, https://sampathblogs.online/wp-content/uploads/2020/01/filter-295x300.jpg 295w" sizes="auto, (max-width: 480px) 100vw, 480px" /><p id="caption-attachment-1292" class="wp-caption-text">Auto Filter</p></div>
<p>The Auto filter option in the above code would give the above figure output in excel. However only the header has been added through code and the other data has been input manually. As we can see here, the filter options get selected through code, but unless we click on the OK button for the first column option and the sort.. option in the second column we will not get the result. Refer to the figure to get a clear picture of before and after filtering.</p>
<h4>Charts</h4>
<p>In the final section, we will be working on <strong>charts and chart sheets</strong>. However, <em>Matplotlib</em> is the most used library for plotting in python.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from openpyxl import Workbook                      # Module needed for creating new workbook
from openpyxl import load_workbook                 # Module needed for loading existing workbook

from openpyxl.chart import BarChart, ScatterChart, PieChart, Reference, AreaChart, Series

wb=Workbook()
filename = "testcharts.xlsx"

wb = load_workbook(filename)
sheet = wb.active

series1 = Reference(sheet, min_col=1, min_row=1, max_col=1, max_row=10)    
series2 = Reference(sheet, min_col=2, min_row=1, max_col=2, max_row=10)

bar_chart = BarChart()                                                #barchart
bar_chart.add_data(series1, titles_from_data=True)
bar_chart.add_data(series2, titles_from_data=True)
bar_chart.title = "Bar Chart"
bar_chart.style = 11
bar_chart.x_axis.title = 'Size'
bar_chart.y_axis.title = 'Percentage'
sheet.add_chart(bar_chart, "A16")    

##cs = wb.create_chartsheet()                                         #chartsheet
##
##chart = AreaChart()
##chart.title = "Area Chart"
##chart.style = 13
##chart.x_axis.title = 'machida'
##chart.y_axis.title = 'odawara'
##data = Reference(sheet, min_col=12, min_row=1, max_row=10)
##categories = Reference(sheet, min_col=11, min_row=1, max_row=10)
##chart.add_data(data, titles_from_data=False)
##chart.set_categories(categories)
##
##cs.add_chart(chart)


wb.save(filename)                                                      #save the above data</pre>
<p>In the above code, we read the data present in ten rows, two columns and represented the same in bar chart as shown in the below figure. Also in the commented out section we are making use of the chart sheet facility available so that we can display the chart in a separate sheet.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-1252 size-full" src="https://sampathblogs.online/wp-content/uploads/2020/01/barchart.jpg" alt="" width="730" height="291" srcset="https://sampathblogs.online/wp-content/uploads/2020/01/barchart.jpg 730w, https://sampathblogs.online/wp-content/uploads/2020/01/barchart-300x120.jpg 300w, https://sampathblogs.online/wp-content/uploads/2020/01/barchart-600x239.jpg 600w" sizes="auto, (max-width: 730px) 100vw, 730px" /></p>
<p><strong>Credits:</strong><br />
<em>Self study (<a href="http://www.udemy.com">www.udemy.com</a>)</em><br />
<em><a href="http://openpyxl.readthedocs.io">openpyxl.readthedocs.io</a></em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sampathblogs.online/2019/09/working-on-ms-excel-using-python-openpyxl-library/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
