Python | Trigonometric operations in excel file using openpyxl Last Updated : 21 Aug, 2018 Comments Improve Suggest changes Like Article Like Report Prerequisite : Adjusting rows and columns of an excel sheet using openpyxl. Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, mathematical operations and plotting graphs. Let’s see how to perform different Trigonometric operations using openpyxl. Simple trigonometric functions : Code #1 : Using simple trigonometric functions in the program. =SIN(Number) : Returns the sine of an angle. Number is the angle in radians for which you want the sine. =COS(Number) : Returns the cosine of an angle. =TAN(Number) : Returns the tangent of an angle. =CSC(Number) : Returns the cosecant of an angle. =SEC(Number) : Returns the secant of an angle. =COT(Number) : Returns the cotangent of an angle. Python3 # import openpyxl module import openpyxl # Call a Workbook() function of openpyxl # to create a new blank Workbook object wb = openpyxl.Workbook() # Get workbook active sheet # from the active attribute. sheet = wb.active # set the width of the column sheet.column_dimensions['A'].width = 20 sheet.column_dimensions['B'].width = 30 sheet.column_dimensions['C'].width = 20 # writing to the cell of an excel sheet sheet['A1'] = "angles in radian" sheet['A2'] = 0.1 sheet['A3'] = 0.2 sheet['A4'] = 0.3 sheet['A5'] = 0.4 sheet['A6'] = 0.5 sheet['A7'] = 0.6 # mention performing trigonometric operations sheet['B1'] = "Applying trigonometric function" sheet['B2'] = "Sine" sheet['B3'] = "Cosine" sheet['B4'] = "Tangent" sheet['B5'] = "Cosecant" sheet['B6'] = "Secant" sheet['B7'] = "Cotangent" # The value in cell C1 to C7 is set to a formula # that calculates values for particular radian. sheet['C1'] = 'corresponding values' sheet['C2'] = '= SIN(0.1)' sheet['C3'] = '= COS(0.2)' sheet['C4'] = '= TAN(0.3)' sheet['C5'] = '= CSC(0.4)' sheet['C6'] = '= SEC(0.5)' sheet['C7'] = '= COT(0.6)' # save the file wb.save("simple_trigonometric.xlsx") Output: Code #2 : Using hyperbolic trigonometric functions in the program. =SINH(Number) : Returns the hyperbolic sine of a Number. =COSH(Number) : Returns the hyperbolic cosine of a Number. =TANH(number) : Returns the hyperbolic tangent of a Number. =CSCH(Number) : Returns the hyperbolic cosecant of a Number. =SECH(Number) : Returns the hyperbolic secant of a Number. =COTH(Number) : Returns the hyperbolic cotangent of a Number. Python3 # import openpyxl module import openpyxl # Call a Workbook() function of openpyxl # to create a new blank Workbook object wb = openpyxl.Workbook() # Get workbook active sheet # from the active attribute. sheet = wb.active # set the width of the column sheet.column_dimensions['A'].width = 20 sheet.column_dimensions['B'].width = 30 sheet.column_dimensions['C'].width = 20 # writing to the cell of an excel sheet sheet['A1'] = "angles in radian" sheet['A2'] = 0.1 sheet['A3'] = 0.2 sheet['A4'] = 0.3 sheet['A5'] = 0.4 sheet['A6'] = 0.5 sheet['A7'] = 0.6 # mention performing trigonometric operations sheet['B1'] = "Applying trigonometric function" sheet['B2'] = "Hyperbolic Sine" sheet['B3'] = "Hyperbolic Cosine" sheet['B4'] = "Hyperbolic Tangent" sheet['B5'] = "Hyperbolic Cosecant" sheet['B6'] = "Hyperbolic Secant" sheet['B7'] = "Hyperbolic Cotangent" # The value in cell C1 to C7 is set to a formula # that calculates values for particular radian. sheet['C1'] = 'corresponding values' sheet['C2'] = '= SINH(0.1)' sheet['C3'] = '= COSH(0.2)' sheet['C4'] = '= TANH(0.3)' sheet['C5'] = '= CSCH(0.4)' sheet['C6'] = '= SECH(0.5)' sheet['C7'] = '= COTH(0.6)' # save the file wb.save("Hyperbolic_trigonometric.xlsx") Output: Comment More infoAdvertise with us Next Article Python | Trigonometric operations in excel file using openpyxl ankthon Follow Improve Article Tags : Python python-modules Practice Tags : python Similar Reads Python | Arithmetic operations in excel file using openpyxl Prerequisite: Reading & Writing to excel sheet using openpyxlOpenpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Let's see how to perform different arithmetic operations using openpyxl.  =S 3 min read Reading an excel file using Python openpyxl module Openpyxl is a Python library for reading and writing Excel (with extension xlsx/xlsm/xltx/xltm) files. The Openpyxl Module allows Python programs to read and modify Excel files. For example, users might have to go through thousands of rows and pick out a few handfuls of information to make small cha 3 min read Python | Writing to an excel file using openpyxl module Prerequisite : Reading an excel file using openpyxl Openpyxl is a Python library for reading and writing Excel (with extension xlsx/xlsm/xltx/xltm) files. The openpyxl module allows Python program to read and modify Excel files. For example, user might have to go through thousands of rows and pick o 3 min read Python | Plotting charts in excel sheet using openpyxl module | Set - 1 Prerequisite: Reading & Writing to excel sheet using openpyxl Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Let's see how to plot different charts using realtime data. Charts are compo 6 min read Python | Plotting charts in excel sheet using openpyxl module | Set â 2 Prerequisite: Python | Plotting charts in excel sheet using openpyxl module | Set â 1 Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Charts are composed of at least one series of one or mor 6 min read Python | Plotting charts in excel sheet using openpyxl module | Set 3 Prerequisite : Plotting charts in excel sheet using openpyxl module Set - 1 | Set â 2Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Charts are composed of at least one series of one or more 7 min read How to import an excel file into Python using Pandas? It is not always possible to get the dataset in CSV format. So, Pandas provides us the functions to convert datasets in other formats to the Data frame. An excel file has a '.xlsx' format. Before we get started,  we need to install a few libraries. pip install pandas pip install xlrd  For importin 2 min read Formatting Cells using openpyxl in Python When it comes to managing Excel files programmatically, Python offers a powerful tool in the form of the openpyxl library. This library not only allows us to read and write Excel documents but also provides extensive support for cell formatting. From fonts and colors to alignment and borders, openpy 4 min read Merge and Unmerge Excel Cells using openpyxl in Python In this article, we are going to learn about Python programs to merge and unmerge excel cells using openpyxl.IntroductionOpenpyxl is a Python library commonly used for reading and writing Excel Files. In this article, we will be using this library to merge cells in Excel. Merging is helpful when we 4 min read Like