
Excel
- 163 installs
- 125 repo stars
- Updated February 4, 2026
- igorwarzocha/opencode-workflows
Read, edit, and restructure Excel spreadsheets so agents can update reports, clean tabular data, and maintain recurring business workbooks without manual spreadsheet labor.
About
Excel skill from opencode-workflows equips Claude to open, read, edit, and restructure Excel spreadsheets for reporting and data cleanup, handling formulas, columns, and messy tabular input in recurring business document workflows.
- Opens and edits .xlsx workbook structures
- Cleans and reformats messy tabular data
- Updates formulas, columns, and report layouts
- Supports recurring business spreadsheet tasks
- Reduces manual Excel copy-paste workflows
Excel by the numbers
- 163 all-time installs (skills.sh)
- +9 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #278 of 688 Office & Documents skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/igorwarzocha/opencode-workflows --skill excelAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 163 |
|---|---|
| repo stars | ★ 125 |
| Last updated | February 4, 2026 |
| Repository | igorwarzocha/opencode-workflows ↗ |
What it does
Read, edit, and restructure Excel spreadsheets so agents can update reports, clean tabular data, and maintain recurring business workbooks without manual spreadsheet labor.
Files
<instructions> <excel_professional_suite>
<modeling_standards>
- Zero Formula Errors: Models MUST have zero #REF!, #DIV/0!, or #VALUE! errors.
- Dynamic Logic: You MUST NOT hardcode derived values. You MUST use Excel formulas for all calculations.
- Assumptions: You MUST place all inputs in dedicated assumption cells.
</modeling_standards>
<professional_formatting>
- Standards: Specify units in headers ("Revenue ($mm)"). Format zeros as "-".
- Color Coding: The agent SHOULD follow the project's
brandingskill for color choices. If not defined, the agent SHOULD default to professional standards (e.g., Blue for hardcoded inputs, Black for formulas). - Visuals: You SHOULD use
artifact_toolto render sheets and verify layout. Reference:references/artifact_tool_spreadsheets_api.md.
</professional_formatting>
<technical_workflows>
1. Data Analysis (Pandas)
- You SHOULD use Pandas for heavy lifting and aggregation.
- You SHOULD convert to Openpyxl for final professional formatting and formula insertion.
2. Verification Loop (MANDATORY)
Before delivery, you MUST run the audit script:
python scripts/recalc.py output.xlsx- You MUST fix all errors identified in the resulting JSON summary.
</technical_workflows>
<citation_logic>
- Citations: You SHOULD cite sources for hardcoded data in cell comments.
- Best Practices: See
references/spreadsheet.mdfor guidance on cross-sheet references and complex formula construction.
</citation_logic>
</excel_professional_suite> </instructions>
Artifact Tool: Supported Spreadsheet Formulas
Generated on 12/06/2025 at 6:58 +0000
These are the set of formulas that are supported or unsupported in artifact_tool for recalculation. Even if the function is unsupported, you may still set a cell's formula to that function, but it will not calculate properly and instead produce an error like #NAME? or #ERROR? but upon export, it may still work.
Number of formulas: 520 (Implemented: 399, Not implemented: 121)
| Function Name | Category | Description | Implemented |
|---|---|---|---|
| ABS | Math and trigonometry | Returns the absolute value of a number | Yes |
| ACCRINT | Financial | Returns the accrued interest for a security that pays periodic interest | Yes |
| ACCRINTM | Financial | Returns the accrued interest for a security that pays interest at maturity | No |
| ACOS | Math and trigonometry | Returns the arccosine of a number | Yes |
| ACOSH | Math and trigonometry | Returns the inverse hyperbolic cosine of a number | Yes |
| ACOT | Math and trigonometry | Returns the arccotangent of a number | Yes |
| ACOTH | Math and trigonometry | Returns the hyperbolic arccotangent of a number | Yes |
| ADDRESS | Lookup and reference | Returns a reference as text to a single cell in a worksheet | No |
| AGGREGATE | Math and trigonometry | Returns an aggregate in a list or database | Yes |
| AMORDEGRC | Financial | Returns the depreciation for each accounting period by using a depreciation coefficient | No |
| AMORLINC | Financial | Returns the depreciation for each accounting period | No |
| AND | Logical | Returns TRUE if all of its arguments are TRUE | Yes |
| ARABIC | Math and trigonometry | Converts a Roman number to Arabic, as a number | Yes |
| AREAS | Lookup and reference | Returns the number of areas in a reference | No |
| ARRAYTOTEXT | Text | Returns an array of text values from any specified range | No |
| ASC | Text | Changes full-width (double-byte) English letters or katakana within a character string to half-width (single-byte) characters | No |
| ASIN | Math and trigonometry | Returns the arcsine of a number | Yes |
| ASINH | Math and trigonometry | Returns the inverse hyperbolic sine of a number | Yes |
| ATAN | Math and trigonometry | Returns the arctangent of a number | Yes |
| ATAN2 | Math and trigonometry | Returns the arctangent from x- and y-coordinates | Yes |
| ATANH | Math and trigonometry | Returns the inverse hyperbolic tangent of a number | Yes |
| AVEDEV | Statistical | Returns the average of the absolute deviations of data points from their mean | Yes |
| AVERAGE | Statistical | Returns the average of its arguments | Yes |
| AVERAGEA | Statistical | Returns the average of its arguments, including numbers, text, and logical values | Yes |
| AVERAGEIF | Statistical | Returns the average (arithmetic mean) of all the cells in a range that meet a given criteria | Yes |
| AVERAGEIFS | Statistical | Returns the average (arithmetic mean) of all cells that meet multiple criteria | Yes |
| BAHTTEXT | Text | Converts a number to text, using the ß (baht) currency format | No |
| BASE | Math and trigonometry | Converts a number into a text representation with the given radix (base) | Yes |
| BESSELI | Engineering | Returns the modified Bessel function In(x) | Yes |
| BESSELJ | Engineering | Returns the Bessel function Jn(x) | Yes |
| BESSELK | Engineering | Returns the modified Bessel function Kn(x) | Yes |
| BESSELY | Engineering | Returns the Bessel function Yn(x) | Yes |
| BETA.DIST | Statistical | Returns the beta cumulative distribution function | Yes |
| BETA.INV | Statistical | Returns the inverse of the cumulative distribution function for a specified beta distribution | Yes |
| BETADIST | Compatibility | Returns the beta cumulative distribution function | Yes |
| BETAINV | Compatibility | Returns the inverse of the cumulative distribution function for a specified beta distribution | Yes |
| BIN2DEC | Engineering | Converts a binary number to decimal | Yes |
| BIN2HEX | Engineering | Converts a binary number to hexadecimal | Yes |
| BIN2OCT | Engineering | Converts a binary number to octal | Yes |
| BINOM.DIST | Statistical | Returns the individual term binomial distribution probability | Yes |
| BINOM.DIST.RANGE | Statistical | Returns the probability of a trial result using a binomial distribution | Yes |
| BINOM.INV | Statistical | Returns the smallest value for which the cumulative binomial distribution is less than or equal to a criterion value | Yes |
| BINOMDIST | Compatibility | Returns the individual term binomial distribution probability | Yes |
| BITAND | Engineering | Returns a 'Bitwise And' of two numbers | Yes |
| BITLSHIFT | Engineering | Returns a value number shifted left by shift_amount bits | Yes |
| BITOR | Engineering | Returns a bitwise OR of 2 numbers | Yes |
| BITRSHIFT | Engineering | Returns a value number shifted right by shift_amount bits | Yes |
| BITXOR | Engineering | Returns a bitwise 'Exclusive Or' of two numbers | Yes |
| BYCOL | Logical | Applies a LAMBDA to each column and returns an array of the results | No |
| BYROW | Logical | Applies a LAMBDA to each row and returns an array of the results | No |
| CALL | User defined functions that are installed with add-ins | Calls a procedure in a dynamic link library or code resource | No |
| CEILING | Math and trigonometry | Rounds a number to the nearest integer or to the nearest multiple of significance | Yes |
| CEILING.MATH | Math and trigonometry | Rounds a number up, to the nearest integer or to the nearest multiple of significance | Yes |
| CEILING.PRECISE | Math and trigonometry | Rounds a number the nearest integer or to the nearest multiple of significance. Regardless of the sign of the number, the number is rounded up. | Yes |
| CELL | Information | Returns information about the formatting, location, or contents of a cell | No |
| CHAR | Text | Returns the character specified by the code number | Yes |
| CHIDIST | Compatibility | Returns the one-tailed probability of the chi-squared distribution | Yes |
| CHIINV | Compatibility | Returns the inverse of the one-tailed probability of the chi-squared distribution | Yes |
| CHISQ.DIST | Statistical | Returns the cumulative beta probability density function | Yes |
| CHISQ.DIST.RT | Statistical | Returns the one-tailed probability of the chi-squared distribution | Yes |
| CHISQ.INV | Statistical | Returns the cumulative beta probability density function | Yes |
| CHISQ.INV.RT | Statistical | Returns the inverse of the one-tailed probability of the chi-squared distribution | Yes |
| CHISQ.TEST | Statistical | Returns the test for independence | Yes |
| CHITEST | Compatibility | Returns the test for independence | Yes |
| CHOOSE | Lookup and reference | Chooses a value from a list of values | Yes |
| CHOOSECOLS | Lookup and reference | Returns the specified columns from an array | No |
| CHOOSEROWS | Lookup and reference | Returns the specified rows from an array | No |
| CLEAN | Text | Removes all nonprintable characters from text | Yes |
| CODE | Text | Returns a numeric code for the first character in a text string | Yes |
| COLUMN | Lookup and reference | Returns the column number of a reference | Yes |
| COLUMNS | Lookup and reference | Returns the number of columns in a reference | Yes |
| COMBIN | Math and trigonometry | Returns the number of combinations for a given number of objects | Yes |
| COMBINA | Math and trigonometry | Returns the number of combinations with repetitions for a given number of items | Yes |
| COMPLEX | Engineering | Converts real and imaginary coefficients into a complex number | Yes |
| CONCAT | Text | Combines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments. | Yes |
| CONCATENATE | Compatibility | Joins two or more text strings into one string | Yes |
| CONFIDENCE | Compatibility | Returns the confidence interval for a population mean | No |
| CONFIDENCE.NORM | Statistical | Returns the confidence interval for a population mean | Yes |
| CONFIDENCE.T | Statistical | Returns the confidence interval for a population mean, using a Student's t distribution | Yes |
| CONVERT | Engineering | Converts a number from one measurement system to another | Yes |
| CORREL | Statistical | Returns the correlation coefficient between two data sets | Yes |
| COS | Math and trigonometry | Returns the cosine of a number | Yes |
| COSH | Math and trigonometry | Returns the hyperbolic cosine of a number | Yes |
| COT | Math and trigonometry | Returns the cotangent of an angle | Yes |
| COTH | Math and trigonometry | Returns the hyperbolic cotangent of a number | Yes |
| COUNT | Statistical | Counts how many numbers are in the list of arguments | Yes |
| COUNTA | Statistical | Counts how many values are in the list of arguments | Yes |
| COUNTBLANK | Statistical | Counts the number of blank cells within a range | Yes |
| COUNTIF | Statistical | Counts the number of cells within a range that meet the given criteria | Yes |
| COUNTIFS | Statistical | Counts the number of cells within a range that meet multiple criteria | Yes |
| COUPDAYBS | Financial | Returns the number of days from the beginning of the coupon period to the settlement date | No |
| COUPDAYS | Financial | Returns the number of days in the coupon period that contains the settlement date | Yes |
| COUPDAYSNC | Financial | Returns the number of days from the settlement date to the next coupon date | No |
| COUPNCD | Financial | Returns the next coupon date after the settlement date | No |
| COUPNUM | Financial | Returns the number of coupons payable between the settlement date and maturity date | No |
| COUPPCD | Financial | Returns the previous coupon date before the settlement date | No |
| COVAR | Compatibility | Returns covariance, the average of the products of paired deviations | Yes |
| COVARIANCE.P | Statistical | Returns covariance, the average of the products of paired deviations | Yes |
| COVARIANCE.S | Statistical | Returns the sample covariance, the average of the products deviations for each data point pair in two data sets | Yes |
| CRITBINOM | Compatibility | Returns the smallest value for which the cumulative binomial distribution is less than or equal to a criterion value | Yes |
| CSC | Math and trigonometry | Returns the cosecant of an angle | Yes |
| CSCH | Math and trigonometry | Returns the hyperbolic cosecant of an angle | Yes |
| CUBEKPIMEMBER | Cubes | Returns a key performance indicator (KPI) property and displays the KPI name in the cell. A KPI is a quantifiable measurement, such as monthly gross profit or quarterly employee turnover, that is used to monitor an organization's performance. | No |
| CUBEMEMBER | Cubes | Returns a member or tuple from the cube. Use to validate that the member or tuple exists in the cube. | No |
| CUBEMEMBERPROPERTY | Cubes | Returns the value of a member property from the cube. Use to validate that a member name exists within the cube and to return the specified property for this member. | No |
| CUBERANKEDMEMBER | Cubes | Returns the nth, or ranked, member in a set. Use to return one or more elements in a set, such as the top sales performer or the top 10 students. | No |
| CUBESET | Cubes | Defines a calculated set of members or tuples by sending a set expression to the cube on the server, which creates the set, and then returns that set to Microsoft Excel. | No |
| CUBESETCOUNT | Cubes | Returns the number of items in a set. | No |
| CUBEVALUE | Cubes | Returns an aggregated value from the cube. | No |
| CUMIPMT | Financial | Returns the cumulative interest paid between two periods | Yes |
| CUMPRINC | Financial | Returns the cumulative principal paid on a loan between two periods | Yes |
| DATE | Date and time | Returns the serial number of a particular date | Yes |
| DATEDIF | Date and time | Calculates the number of days, months, or years between two dates. This function is useful in formulas where you need to calculate an age. | Yes |
| DATEVALUE | Date and time | Converts a date in the form of text to a serial number | Yes |
| DAVERAGE | Database | Returns the average of selected database entries | Yes |
| DAY | Date and time | Converts a serial number to a day of the month | Yes |
| DAYS | Date and time | Returns the number of days between two dates | Yes |
| DAYS360 | Date and time | Calculates the number of days between two dates based on a 360-day year | Yes |
| DB | Financial | Returns the depreciation of an asset for a specified period by using the fixed-declining balance method | Yes |
| DBCS | Text | Changes half-width (single-byte) English letters or katakana within a character string to full-width (double-byte) characters | No |
| DCOUNT | Database | Counts the cells that contain numbers in a database | Yes |
| DCOUNTA | Database | Counts nonblank cells in a database | Yes |
| DDB | Financial | Returns the depreciation of an asset for a specified period by using the double-declining balance method or some other method that you specify | Yes |
| DEC2BIN | Engineering | Converts a decimal number to binary | Yes |
| DEC2HEX | Engineering | Converts a decimal number to hexadecimal | Yes |
| DEC2OCT | Engineering | Converts a decimal number to octal | Yes |
| DECIMAL | Math and trigonometry | Converts a text representation of a number in a given base into a decimal number | Yes |
| DEGREES | Math and trigonometry | Converts radians to degrees | Yes |
| DELTA | Engineering | Tests whether two values are equal | Yes |
| DETECTLANGUAGE | Text | Identifies the language of a specified text | No |
| DEVSQ | Statistical | Returns the sum of squares of deviations | Yes |
| DGET | Database | Extracts from a database a single record that matches the specified criteria | Yes |
| DISC | Financial | Returns the discount rate for a security | Yes |
| DMAX | Database | Returns the maximum value from selected database entries | Yes |
| DMIN | Database | Returns the minimum value from selected database entries | Yes |
| DOLLAR | Text | Converts a number to text, using the $ (dollar) currency format | Yes |
| DOLLARDE | Financial | Converts a dollar price, expressed as a fraction, into a dollar price, expressed as a decimal number | Yes |
| DOLLARFR | Financial | Converts a dollar price, expressed as a decimal number, into a dollar price, expressed as a fraction | Yes |
| DPRODUCT | Database | Multiplies the values in a particular field of records that match the criteria in a database | Yes |
| DROP | Lookup and reference | Excludes a specified number of rows or columns from the start or end of an array | No |
| DSTDEV | Database | Estimates the standard deviation based on a sample of selected database entries | Yes |
| DSTDEVP | Database | Calculates the standard deviation based on the entire population of selected database entries | Yes |
| DSUM | Database | Adds the numbers in the field column of records in the database that match the criteria | Yes |
| DURATION | Financial | Returns the annual duration of a security with periodic interest payments | No |
| DVAR | Database | Estimates variance based on a sample from selected database entries | Yes |
| DVARP | Database | Calculates variance based on the entire population of selected database entries | Yes |
| EDATE | Date and time | Returns the serial number of the date that is the indicated number of months before or after the start date | Yes |
| EFFECT | Financial | Returns the effective annual interest rate | Yes |
| ENCODEURL | Web | Returns a URL-encoded string | No |
| EOMONTH | Date and time | Returns the serial number of the last day of the month before or after a specified number of months | Yes |
| ERF | Engineering | Returns the error function | Yes |
| ERF.PRECISE | Engineering | Returns the error function | No |
| ERFC | Engineering | Returns the complementary error function | Yes |
| ERFC.PRECISE | Engineering | Returns the complementary ERF function integrated between x and infinity | No |
| ERROR.TYPE | Information | Returns a number corresponding to an error type | Yes |
| EUROCONVERT | User defined functions that are installed with add-ins | Converts a number to euros, converts a number from euros to a euro member currency, or converts a number from one euro member currency to another by using the euro as an intermediary (triangulation) | No |
| EVEN | Math and trigonometry | Rounds a number up to the nearest even integer | Yes |
| EXACT | Text | Checks to see if two text values are identical | Yes |
| EXP | Math and trigonometry | Returns e raised to the power of a given number | Yes |
| EXPAND | Lookup and reference | Expands or pads an array to specified row and column dimensions | No |
| EXPON.DIST | Statistical | Returns the exponential distribution | Yes |
| EXPONDIST | Compatibility | Returns the exponential distribution | Yes |
| F.DIST | Statistical | Returns the F probability distribution | Yes |
| F.DIST.RT | Statistical | Returns the F probability distribution | Yes |
| F.INV | Statistical | Returns the inverse of the F probability distribution | Yes |
| F.INV.RT | Statistical | Returns the inverse of the F probability distribution | Yes |
| F.TEST | Statistical | Returns the result of an F-test | Yes |
| FACT | Math and trigonometry | Returns the factorial of a number | Yes |
| FACTDOUBLE | Math and trigonometry | Returns the double factorial of a number | Yes |
| FALSE | Logical | Returns the logical value FALSE | Yes |
| FDIST | Compatibility | Returns the F probability distribution | Yes |
| FILTER | Lookup and reference | Filters a range of data based on criteria you define | No |
| FILTERXML | Web | Returns specific data from the XML content by using the specified XPath | No |
| FIND | Text | Finds one text value within another (case-sensitive) | Yes |
| FINDB | Text | Finds one text value within another (case-sensitive) | No |
| FINV | Compatibility | Returns the inverse of the F probability distribution | Yes |
| FISHER | Statistical | Returns the Fisher transformation | Yes |
| FISHERINV | Statistical | Returns the inverse of the Fisher transformation | Yes |
| FIXED | Text | Formats a number as text with a fixed number of decimals | Yes |
| FLOOR | Compatibility | Rounds a number down, toward zero | Yes |
| FLOOR.MATH | Math and trigonometry | Rounds a number down, to the nearest integer or to the nearest multiple of significance | Yes |
| FLOOR.PRECISE | Math and trigonometry | Rounds a number down to the nearest integer or to the nearest multiple of significance. Regardless of the sign of the number, the number is rounded down. | Yes |
| FORECAST | Compatibility | Calculates, or predicts, a future value by using existing values. | Yes |
| FORECAST.ETS | Statistical | Returns a future value based on existing (historical) values by using the AAA version of the Exponential Smoothing (ETS) algorithm | No |
| FORECAST.ETS.CONFINT | Statistical | Returns a confidence interval for the forecast value at the specified target date | No |
| FORECAST.ETS.SEASONALITY | Statistical | Returns the length of the repetitive pattern Excel detects for the specified time series | No |
| FORECAST.ETS.STAT | Statistical | Returns a statistical value as a result of time series forecasting | No |
| FORECAST.LINEAR | Statistical | Returns a future value based on existing values | No |
| FORMULATEXT | Lookup and reference | Returns the formula at the given reference as text | No |
| FREQUENCY | Statistical | Returns a frequency distribution as a vertical array | Yes |
| FTEST | Compatibility | Returns the result of an F-test | Yes |
| FV | Financial | Returns the future value of an investment | Yes |
| FVSCHEDULE | Financial | Returns the future value of an initial principal after applying a series of compound interest rates | Yes |
| GAMMA | Statistical | Returns the Gamma function value | Yes |
| GAMMA.DIST | Statistical | Returns the gamma distribution | Yes |
| GAMMA.INV | Statistical | Returns the inverse of the gamma cumulative distribution | Yes |
| GAMMADIST | Compatibility | Returns the gamma distribution | Yes |
| GAMMAINV | Compatibility | Returns the inverse of the gamma cumulative distribution | Yes |
| GAMMALN | Statistical | Returns the natural logarithm of the gamma function, Γ(x) | Yes |
| GAMMALN.PRECISE | Statistical | Returns the natural logarithm of the gamma function, Γ(x) | Yes |
| GAUSS | Statistical | Returns 0.5 less than the standard normal cumulative distribution | Yes |
| GCD | Math and trigonometry | Returns the greatest common divisor | Yes |
| GEOMEAN | Statistical | Returns the geometric mean | Yes |
| GESTEP | Engineering | Tests whether a number is greater than a threshold value | Yes |
| GETPIVOTDATA | Lookup and reference | Returns data stored in a PivotTable report | No |
| GROUPBY | Lookup and reference | Helps a user group, aggregate, sort, and filter data based on the fields you specify | No |
| GROWTH | Statistical | Returns values along an exponential trend | Yes |
| HARMEAN | Statistical | Returns the harmonic mean | Yes |
| HEX2BIN | Engineering | Converts a hexadecimal number to binary | Yes |
| HEX2DEC | Engineering | Converts a hexadecimal number to decimal | Yes |
| HEX2OCT | Engineering | Converts a hexadecimal number to octal | Yes |
| HLOOKUP | Lookup and reference | Looks in the top row of an array and returns the value of the indicated cell | Yes |
| HOUR | Date and time | Converts a serial number to an hour | Yes |
| HSTACK | Lookup and reference | Appends arrays horizontally and in sequence to return a larger array | No |
| HYPERLINK | Lookup and reference | Creates a shortcut or jump that opens a document stored on a network server, an intranet, or the Internet | No |
| HYPGEOM.DIST | Statistical | Returns the hypergeometric distribution | Yes |
| HYPGEOMDIST | Compatibility | Returns the hypergeometric distribution | Yes |
| IF | Logical | Specifies a logical test to perform | Yes |
| IFERROR | Logical | Returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula | Yes |
| IFNA | Logical | Returns the value you specify if the expression resolves to #N/A, otherwise returns the result of the expression | Yes |
| IFS | Logical | Checks whether one or more conditions are met and returns a value that corresponds to the first TRUE condition. | Yes |
| IMABS | Engineering | Returns the absolute value (modulus) of a complex number | Yes |
| IMAGE | Lookup and reference | Returns an image from a given source | No |
| IMAGINARY | Engineering | Returns the imaginary coefficient of a complex number | Yes |
| IMARGUMENT | Engineering | Returns the argument theta, an angle expressed in radians | Yes |
| IMCONJUGATE | Engineering | Returns the complex conjugate of a complex number | Yes |
| IMCOS | Engineering | Returns the cosine of a complex number | Yes |
| IMCOSH | Engineering | Returns the hyperbolic cosine of a complex number | Yes |
| IMCOT | Engineering | Returns the cotangent of a complex number | Yes |
| IMCSC | Engineering | Returns the cosecant of a complex number | Yes |
| IMCSCH | Engineering | Returns the hyperbolic cosecant of a complex number | Yes |
| IMDIV | Engineering | Returns the quotient of two complex numbers | Yes |
| IMEXP | Engineering | Returns the exponential of a complex number | Yes |
| IMLN | Engineering | Returns the natural logarithm of a complex number | Yes |
| IMLOG10 | Engineering | Returns the base-10 logarithm of a complex number | Yes |
| IMLOG2 | Engineering | Returns the base-2 logarithm of a complex number | Yes |
| IMPOWER | Engineering | Returns a complex number raised to an integer power | Yes |
| IMPRODUCT | Engineering | Returns the product of from 2 to 255 complex numbers | Yes |
| IMREAL | Engineering | Returns the real coefficient of a complex number | Yes |
| IMSEC | Engineering | Returns the secant of a complex number | Yes |
| IMSECH | Engineering | Returns the hyperbolic secant of a complex number | Yes |
| IMSIN | Engineering | Returns the sine of a complex number | Yes |
| IMSINH | Engineering | Returns the hyperbolic sine of a complex number | Yes |
| IMSQRT | Engineering | Returns the square root of a complex number | Yes |
| IMSUB | Engineering | Returns the difference between two complex numbers | Yes |
| IMSUM | Engineering | Returns the sum of complex numbers | Yes |
| IMTAN | Engineering | Returns the tangent of a complex number | Yes |
| INDEX | Lookup and reference | Uses an index to choose a value from a reference or array | Yes |
| INDIRECT | Lookup and reference | Returns a reference indicated by a text value | No |
| INFO | Information | Returns information about the current operating environment Note: This function is not available in Excel for the web. | No |
| INT | Math and trigonometry | Rounds a number down to the nearest integer | Yes |
| INTERCEPT | Statistical | Returns the intercept of the linear regression line | Yes |
| INTRATE | Financial | Returns the interest rate for a fully invested security | No |
| IPMT | Financial | Returns the interest payment for an investment for a given period | Yes |
| IRR | Financial | Returns the internal rate of return for a series of cash flows | Yes |
| ISBLANK | Information | Returns TRUE if the value is blank | Yes |
| ISERR | Information | Returns TRUE if the value is any error value except #N/A | Yes |
| ISERROR | Information | Returns TRUE if the value is any error value | Yes |
| ISEVEN | Information | Returns TRUE if the number is even | Yes |
| ISFORMULA | Information | Returns TRUE if there is a reference to a cell that contains a formula | No |
| ISLOGICAL | Information | Returns TRUE if the value is a logical value | Yes |
| ISNA | Information | Returns TRUE if the value is the #N/A error value | Yes |
| ISNONTEXT | Information | Returns TRUE if the value is not text | Yes |
| ISNUMBER | Information | Returns TRUE if the value is a number | Yes |
| ISO.CEILING | Math and trigonometry | Returns a number that is rounded up to the nearest integer or to the nearest multiple of significance | Yes |
| ISODD | Information | Returns TRUE if the number is odd | Yes |
| ISOMITTED | Information | Checks whether the value in a LAMBDA is missing and returns TRUE or FALSE | No |
| ISOWEEKNUM | Date and time | Returns the number of the ISO week number of the year for a given date | Yes |
| ISPMT | Financial | Calculates the interest paid during a specific period of an investment | Yes |
| ISREF | Information | Returns TRUE if the value is a reference | No |
| ISTEXT | Information | Returns TRUE if the value is text | Yes |
| KURT | Statistical | Returns the kurtosis of a data set | Yes |
| LAMBDA | Logical | Create custom, reusable functions and call them by a friendly name | No |
| LARGE | Statistical | Returns the k-th largest value in a data set | Yes |
| LCM | Math and trigonometry | Returns the least common multiple | Yes |
| LEFT | Text | Returns the leftmost characters from a text value | Yes |
| LEFTB | Text | Returns the leftmost characters from a text value | No |
| LEN | Text | Returns the number of characters in a text string | Yes |
| LENB | Text | Returns the number of characters in a text string | No |
| LET | Logical | Assigns names to calculation results | No |
| LINEST | Statistical | Returns the parameters of a linear trend | Yes |
| LN | Math and trigonometry | Returns the natural logarithm of a number | Yes |
| LOG | Math and trigonometry | Returns the logarithm of a number to a specified base | Yes |
| LOG10 | Math and trigonometry | Returns the base-10 logarithm of a number | Yes |
| LOGEST | Statistical | Returns the parameters of an exponential trend | Yes |
| LOGINV | Compatibility | Returns the inverse of the lognormal cumulative distribution function | Yes |
| LOGNORM.DIST | Statistical | Returns the cumulative lognormal distribution | Yes |
| LOGNORM.INV | Statistical | Returns the inverse of the lognormal cumulative distribution | Yes |
| LOGNORMDIST | Compatibility | Returns the cumulative lognormal distribution | Yes |
| LOOKUP | Lookup and reference | Looks up values in a vector or array | Yes |
| LOWER | Text | Converts text to lowercase | Yes |
| MAKEARRAY | Logical | Returns a calculated array of a specified row and column size, by applying a LAMBDA | No |
| MAP | Logical | Returns an array formed by mapping each value in the array(s) to a new value by applying a LAMBDA to create a new value | No |
| MATCH | Lookup and reference | Looks up values in a reference or array | Yes |
| MAX | Statistical | Returns the maximum value in a list of arguments | Yes |
| MAXA | Statistical | Returns the maximum value in a list of arguments, including numbers, text, and logical values | Yes |
| MAXIFS | Statistical | Returns the maximum value among cells specified by a given set of conditions or criteria | Yes |
| MDETERM | Math and trigonometry | Returns the matrix determinant of an array | No |
| MDURATION | Financial | Returns the Macauley modified duration for a security with an assumed par value of $100 | No |
| MEDIAN | Statistical | Returns the median of the given numbers | Yes |
| MID | Text | Returns a specific number of characters from a text string starting at the position you specify | Yes |
| MIDB | Text | Returns a specific number of characters from a text string starting at the position you specify | No |
| MIN | Statistical | Returns the minimum value in a list of arguments | Yes |
| MINA | Statistical | Returns the smallest value in a list of arguments, including numbers, text, and logical values | Yes |
| MINIFS | Statistical | Returns the minimum value among cells specified by a given set of conditions or criteria. | Yes |
| MINUTE | Date and time | Converts a serial number to a minute | Yes |
| MINVERSE | Math and trigonometry | Returns the matrix inverse of an array | No |
| MIRR | Financial | Returns the internal rate of return where positive and negative cash flows are financed at different rates | Yes |
| MMULT | Math and trigonometry | Returns the matrix product of two arrays | Yes |
| MOD | Math and trigonometry | Returns the remainder from division | Yes |
| MODE | Compatibility | Returns the most common value in a data set | No |
| MODE.MULT | Statistical | Returns a vertical array of the most frequently occurring, or repetitive values in an array or range of data | Yes |
| MODE.SNGL | Statistical | Returns the most common value in a data set | Yes |
| MONTH | Date and time | Converts a serial number to a month | Yes |
| MROUND | Math and trigonometry | Returns a number rounded to the desired multiple | Yes |
| MULTINOMIAL | Math and trigonometry | Returns the multinomial of a set of numbers | Yes |
| MUNIT | Math and trigonometry | Returns the unit matrix or the specified dimension | Yes |
| N | Information | Returns a value converted to a number | Yes |
| NA | Information | Returns the error value #N/A | Yes |
| NEGBINOM.DIST | Statistical | Returns the negative binomial distribution | Yes |
| NEGBINOMDIST | Compatibility | Returns the negative binomial distribution | Yes |
| NETWORKDAYS | Date and time | Returns the number of whole workdays between two dates | Yes |
| NETWORKDAYS.INTL | Date and time | Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days | Yes |
| NOMINAL | Financial | Returns the annual nominal interest rate | Yes |
| NORM.DIST | Statistical | Returns the normal cumulative distribution | Yes |
| NORM.INV | Statistical | Returns the inverse of the normal cumulative distribution | Yes |
| NORM.S.DIST | Statistical | Returns the standard normal cumulative distribution | Yes |
| NORM.S.INV | Statistical | Returns the inverse of the standard normal cumulative distribution | Yes |
| NORMDIST | Compatibility | Returns the normal cumulative distribution | Yes |
| NORMINV | Compatibility | Returns the inverse of the normal cumulative distribution | Yes |
| NORMSDIST | Compatibility | Returns the standard normal cumulative distribution | Yes |
| NORMSINV | Compatibility | Returns the inverse of the standard normal cumulative distribution | Yes |
| NOT | Logical | Reverses the logic of its argument | Yes |
| NOW | Date and time | Returns the serial number of the current date and time | Yes |
| NPER | Financial | Returns the number of periods for an investment | Yes |
| NPV | Financial | Returns the net present value of an investment based on a series of periodic cash flows and a discount rate | Yes |
| NUMBERVALUE | Text | Converts text to number in a locale-independent manner | Yes |
| OCT2BIN | Engineering | Converts an octal number to binary | Yes |
| OCT2DEC | Engineering | Converts an octal number to decimal | Yes |
| OCT2HEX | Engineering | Converts an octal number to hexadecimal | Yes |
| ODD | Math and trigonometry | Rounds a number up to the nearest odd integer | Yes |
| ODDFPRICE | Financial | Returns the price per $100 face value of a security with an odd first period | No |
| ODDFYIELD | Financial | Returns the yield of a security with an odd first period | No |
| ODDLPRICE | Financial | Returns the price per $100 face value of a security with an odd last period | No |
| ODDLYIELD | Financial | Returns the yield of a security with an odd last period | No |
| OFFSET | Lookup and reference | Returns a reference offset from a given reference | No |
| OR | Logical | Returns TRUE if any argument is TRUE | Yes |
| PDURATION | Financial | Returns the number of periods required by an investment to reach a specified value | Yes |
| PEARSON | Statistical | Returns the Pearson product moment correlation coefficient | Yes |
| PERCENTILE | Compatibility | Returns the k-th percentile of values in a range | No |
| PERCENTILE.EXC | Statistical | Returns the k-th percentile of values in a range, where k is in the range 0..1, exclusive | Yes |
| PERCENTILE.INC | Statistical | Returns the k-th percentile of values in a range | Yes |
| PERCENTOF | Math and trigonometry | Sums the values in the subset and divides it by all the values | No |
| PERCENTRANK | Compatibility | Returns the percentage rank of a value in a data set | No |
| PERCENTRANK.EXC | Statistical | Returns the rank of a value in a data set as a percentage (0..1, exclusive) of the data set | Yes |
| PERCENTRANK.INC | Statistical | Returns the percentage rank of a value in a data set | Yes |
| PERMUT | Statistical | Returns the number of permutations for a given number of objects | Yes |
| PERMUTATIONA | Statistical | Returns the number of permutations for a given number of objects (with repetitions) that can be selected from the total objects | Yes |
| PHI | Statistical | Returns the value of the density function for a standard normal distribution | Yes |
| PHONETIC | Text | Extracts the phonetic (furigana) characters from a text string | No |
| PI | Math and trigonometry | Returns the value of pi | Yes |
| PIVOTBY | Lookup and reference | Helps a user group, aggregate, sort, and filter data based on the row and column fields that you specify | No |
| PMT | Financial | Returns the periodic payment for an annuity | Yes |
| POISSON | Compatibility | Returns the Poisson distribution | No |
| POISSON.DIST | Statistical | Returns the Poisson distribution | Yes |
| POWER | Math and trigonometry | Returns the result of a number raised to a power | Yes |
| PPMT | Financial | Returns the payment on the principal for an investment for a given period | Yes |
| PRICE | Financial | Returns the price per $100 face value of a security that pays periodic interest | No |
| PRICEDISC | Financial | Returns the price per $100 face value of a discounted security | Yes |
| PRICEMAT | Financial | Returns the price per $100 face value of a security that pays interest at maturity | No |
| PROB | Statistical | Returns the probability that values in a range are between two limits | Yes |
| PRODUCT | Math and trigonometry | Multiplies its arguments | Yes |
| PROPER | Text | Capitalizes the first letter in each word of a text value | Yes |
| PV | Financial | Returns the present value of an investment | Yes |
| QUARTILE | Compatibility | Returns the quartile of a data set | No |
| QUARTILE.EXC | Statistical | Returns the quartile of the data set, based on percentile values from 0..1, exclusive | Yes |
| QUARTILE.INC | Statistical | Returns the quartile of a data set | Yes |
| QUOTIENT | Math and trigonometry | Returns the integer portion of a division | Yes |
| RADIANS | Math and trigonometry | Converts degrees to radians | Yes |
| RAND | Math and trigonometry | Returns a random number between 0 and 1 | Yes |
| RANDARRAY | Math and trigonometry | Returns an array of random numbers between 0 and 1. However, you can specify the number of rows and columns to fill, minimum and maximum values, and whether to return whole numbers or decimal values. | No |
| RANDBETWEEN | Math and trigonometry | Returns a random number between the numbers you specify | Yes |
| RANK | Compatibility | Returns the rank of a number in a list of numbers | No |
| RANK.AVG | Statistical | Returns the rank of a number in a list of numbers | Yes |
| RANK.EQ | Statistical | Returns the rank of a number in a list of numbers | Yes |
| RATE | Financial | Returns the interest rate per period of an annuity | Yes |
| RECEIVED | Financial | Returns the amount received at maturity for a fully invested security | No |
| REDUCE | Logical | Reduces an array to an accumulated value by applying a LAMBDA to each value and returning the total value in the accumulator | No |
| REGEXEXTRACT | Text | Extracts strings within the provided text that matches the pattern | No |
| REGEXREPLACE | Text | Replaces strings within the provided text that matches the pattern with replacement | No |
| REGEXTEST | Text | Determines whether any part of text matches the pattern | No |
| REGISTER.ID | User defined functions that are installed with add-ins | Returns the register ID of the specified dynamic link library (DLL) or code resource that has been previously registered | No |
| REPLACE | Text | Replaces characters within text | Yes |
| REPLACEB | Text | Replaces characters within text | No |
| REPT | Text | Repeats text a given number of times | Yes |
| RIGHT | Text | Returns the rightmost characters from a text value | Yes |
| RIGHTB | Text | Returns the rightmost characters from a text value | No |
| ROMAN | Math and trigonometry | Converts an Arabic numeral to Roman, as text | Yes |
| ROUND | Math and trigonometry | Rounds a number to a specified number of digits | Yes |
| ROUNDDOWN | Math and trigonometry | Rounds a number down, toward zero | Yes |
| ROUNDUP | Math and trigonometry | Rounds a number up, away from zero | Yes |
| ROW | Lookup and reference | Returns the row number of a reference | Yes |
| ROWS | Lookup and reference | Returns the number of rows in a reference | Yes |
| RRI | Financial | Returns an equivalent interest rate for the growth of an investment | Yes |
| RSQ | Statistical | Returns the square of the Pearson product moment correlation coefficient | Yes |
| RTD | Lookup and reference | Retrieves real-time data from a program that supports COM automation | No |
| SCAN | Logical | Scans an array by applying a LAMBDA to each value and returns an array that has each intermediate value | No |
| SEARCH | Text | Finds one text value within another (not case-sensitive) | Yes |
| SEARCHB | Text | Finds one text value within another (not case-sensitive) | No |
| SEC | Math and trigonometry | Returns the secant of an angle | Yes |
| SECH | Math and trigonometry | Returns the hyperbolic secant of an angle | Yes |
| SECOND | Date and time | Converts a serial number to a second | Yes |
| SEQUENCE | Math and trigonometry | Generates a list of sequential numbers in an array, such as 1, 2, 3, 4 | No |
| SERIESSUM | Math and trigonometry | Returns the sum of a power series based on the formula | Yes |
| SHEET | Information | Returns the sheet number of the referenced sheet | No |
| SHEETS | Information | Returns the number of sheets in a reference | No |
| SIGN | Math and trigonometry | Returns the sign of a number | Yes |
| SIN | Math and trigonometry | Returns the sine of the given angle | Yes |
| SINH | Math and trigonometry | Returns the hyperbolic sine of a number | Yes |
| SKEW | Statistical | Returns the skewness of a distribution | Yes |
| SKEW.P | Statistical | Returns the skewness of a distribution based on a population: a characterization of the degree of asymmetry of a distribution around its mean | Yes |
| SLN | Financial | Returns the straight-line depreciation of an asset for one period | Yes |
| SLOPE | Statistical | Returns the slope of the linear regression line | Yes |
| SMALL | Statistical | Returns the k-th smallest value in a data set | Yes |
| SORT | Lookup and reference | Sorts the contents of a range or array | Yes |
| SORTBY | Lookup and reference | Sorts the contents of a range or array based on the values in a corresponding range or array | No |
| SQRT | Math and trigonometry | Returns a positive square root | Yes |
| SQRTPI | Math and trigonometry | Returns the square root of (number * pi) | Yes |
| STANDARDIZE | Statistical | Returns a normalized value | Yes |
| STDEV | Compatibility | Estimates standard deviation based on a sample | No |
| STDEV.P | Statistical | Calculates standard deviation based on the entire population | Yes |
| STDEV.S | Statistical | Estimates standard deviation based on a sample | Yes |
| STDEVA | Statistical | Estimates standard deviation based on a sample, including numbers, text, and logical values | Yes |
| STDEVP | Compatibility | Calculates standard deviation based on the entire population | Yes |
| STDEVPA | Statistical | Calculates standard deviation based on the entire population, including numbers, text, and logical values | Yes |
| STEYX | Statistical | Returns the standard error of the predicted y-value for each x in the regression | Yes |
| STOCKHISTORY | Information | Retrieves historical data about a financial instrument | No |
| SUBSTITUTE | Text | Substitutes new text for old text in a text string | Yes |
| SUBTOTAL | Math and trigonometry | Returns a subtotal in a list or database | Yes |
| SUM | Math and trigonometry | Adds its arguments | Yes |
| SUMIF | Math and trigonometry | Adds the cells specified by a given criteria | Yes |
| SUMIFS | Math and trigonometry | Adds the cells in a range that meet multiple criteria | Yes |
| SUMPRODUCT | Math and trigonometry | Returns the sum of the products of corresponding array components | Yes |
| SUMSQ | Math and trigonometry | Returns the sum of the squares of the arguments | Yes |
| SUMX2MY2 | Math and trigonometry | Returns the sum of the difference of squares of corresponding values in two arrays | Yes |
| SUMX2PY2 | Math and trigonometry | Returns the sum of the sum of squares of corresponding values in two arrays | Yes |
| SUMXMY2 | Math and trigonometry | Returns the sum of squares of differences of corresponding values in two arrays | Yes |
| SWITCH | Logical | Evaluates an expression against a list of values and returns the result corresponding to the first matching value. If there is no match, an optional default value may be returned. | Yes |
| SYD | Financial | Returns the sum-of-years' digits depreciation of an asset for a specified period | Yes |
| T | Text | Converts its arguments to text | Yes |
| T.DIST | Statistical | Returns the Percentage Points (probability) for the Student t-distribution | Yes |
| T.DIST.2T | Statistical | Returns the Percentage Points (probability) for the Student t-distribution | Yes |
| T.DIST.RT | Statistical | Returns the Student's t-distribution | Yes |
| T.INV | Statistical | Returns the t-value of the Student's t-distribution as a function of the probability and the degrees of freedom | Yes |
| T.INV.2T | Statistical | Returns the inverse of the Student's t-distribution | Yes |
| T.TEST | Statistical | Returns the probability associated with a Student's t-test | Yes |
| TAKE | Lookup and reference | Returns a specified number of contiguous rows or columns from the start or end of an array | No |
| TAN | Math and trigonometry | Returns the tangent of a number | Yes |
| TANH | Math and trigonometry | Returns the hyperbolic tangent of a number | Yes |
| TBILLEQ | Financial | Returns the bond-equivalent yield for a Treasury bill | Yes |
| TBILLPRICE | Financial | Returns the price per $100 face value for a Treasury bill | Yes |
| TBILLYIELD | Financial | Returns the yield for a Treasury bill | Yes |
| TDIST | Compatibility | Returns the Student's t-distribution | Yes |
| TEXT | Text | Formats a number and converts it to text | Yes |
| TEXTAFTER | Text | Returns text that occurs after given character or string | No |
| TEXTBEFORE | Text | Returns text that occurs before a given character or string | No |
| TEXTJOIN | Text | Text: Combines the text from multiple ranges and/or strings | Yes |
| TEXTSPLIT | Text | Splits text strings by using column and row delimiters | No |
| TIME | Date and time | Returns the serial number of a particular time | Yes |
| TIMEVALUE | Date and time | Converts a time in the form of text to a serial number | Yes |
| TINV | Compatibility | Returns the inverse of the Student's t-distribution | Yes |
| TOCOL | Lookup and reference | Returns the array in a single column | No |
| TODAY | Date and time | Returns the serial number of today's date | Yes |
| TOROW | Lookup and reference | Returns the array in a single row | No |
| TRANSLATE | Text | Translates a text from one language to another | No |
| TRANSPOSE | Lookup and reference | Returns the transpose of an array | Yes |
| TREND | Statistical | Returns values along a linear trend | Yes |
| TRIM | Text | Removes spaces from text | Yes |
| TRIMMEAN | Statistical | Returns the mean of the interior of a data set | Yes |
| TRIMRANGE | Lookup and reference | Scans in from the edges of a range or array until it finds a non-blank cell (or value), it then excludes those blank rows or columns | No |
| TRUE | Logical | Returns the logical value TRUE | Yes |
| TRUNC | Math and trigonometry | Truncates a number to an integer | Yes |
| TTEST | Compatibility | Returns the probability associated with a Student's t-test | Yes |
| TYPE | Information | Returns a number indicating the data type of a value | Yes |
| UNICHAR | Text | Returns the Unicode character that is references by the given numeric value | Yes |
| UNICODE | Text | Returns the number (code point) that corresponds to the first character of the text | Yes |
| UNIQUE | Lookup and reference | Returns a list of unique values in a list or range | Yes |
| UPPER | Text | Converts text to uppercase | Yes |
| VALUE | Text | Converts a text argument to a number | Yes |
| VALUETOTEXT | Text | Returns text from any specified value | No |
| VAR | Compatibility | Estimates variance based on a sample | No |
| VAR.P | Statistical | Calculates variance based on the entire population | Yes |
| VAR.S | Statistical | Estimates variance based on a sample | Yes |
| VARA | Statistical | Estimates variance based on a sample, including numbers, text, and logical values | Yes |
| VARP | Compatibility | Calculates variance based on the entire population | Yes |
| VARPA | Statistical | Calculates variance based on the entire population, including numbers, text, and logical values | Yes |
| VDB | Financial | Returns the depreciation of an asset for a specified or partial period by using a declining balance method | No |
| VLOOKUP | Lookup and reference | Looks in the first column of an array and moves across the row to return the value of a cell | Yes |
| VSTACK | Lookup and reference | Appends arrays vertically and in sequence to return a larger array | No |
| WEBSERVICE | Web | Returns data from a web service | No |
| WEEKDAY | Date and time | Converts a serial number to a day of the week | Yes |
| WEEKNUM | Date and time | Converts a serial number to a number representing where the week falls numerically with a year | Yes |
| WEIBULL | Compatibility | Returns the Weibull distribution | No |
| WEIBULL.DIST | Statistical | Returns the Weibull distribution | Yes |
| WORKDAY | Date and time | Returns the serial number of the date before or after a specified number of workdays | Yes |
| WORKDAY.INTL | Date and time | Returns the serial number of the date before or after a specified number of workdays using parameters to indicate which and how many days are weekend days | Yes |
| WRAPCOLS | Lookup and reference | Wraps the provided row or column of values by columns after a specified number of elements | No |
| WRAPROWS | Lookup and reference | Wraps the provided row or column of values by rows after a specified number of elements | No |
| XIRR | Financial | Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic | Yes |
| XLOOKUP | Lookup and reference | Searches a range or an array, and returns an item corresponding to the first match it finds. If a match doesn't exist, then XLOOKUP can return the closest (approximate) match. | No |
| XMATCH | Lookup and reference | Returns the relative position of an item in an array or range of cells. | No |
| XNPV | Financial | Returns the net present value for a schedule of cash flows that is not necessarily periodic | Yes |
| XOR | Logical | Returns a logical exclusive OR of all arguments | Yes |
| YEAR | Date and time | Converts a serial number to a year | Yes |
| YEARFRAC | Date and time | Returns the year fraction representing the number of whole days between start_date and end_date | Yes |
| YIELD | Financial | Returns the yield on a security that pays periodic interest | No |
| YIELDDISC | Financial | Returns the annual yield for a discounted security; for example, a Treasury bill | No |
| YIELDMAT | Financial | Returns the annual yield of a security that pays interest at maturity | No |
| Z.TEST | Statistical | Returns the one-tailed probability-value of a z-test | Yes |
| ZTEST | Compatibility | Returns the one-tailed probability-value of a z-test | Yes |
artifact_tool
artifact_tool is a python library (wrapper around our C* format) for our model to create/edit/update artifacts (spreadsheets, slides, docs). It will also support rendering (outputs an image) and formula evaluation (for spreadsheets) for the model to evaluate its work.
Usage
from artifact_tool import SpreadsheetArtifact, PresentationArtifact
from artifact_tool.spreadsheet import SpreadsheetSheet
from artifact_tool.presentation import PresentationSlideArtifact Base (Parent abstract class of SpreadsheetArtifact)
Artifact
Base dataclass for any artifact managed by the tool.
allowed_file_extensions(cls) -> list[str]- Return the list of allowed file extensions for the artifact.
- Args
cls- Returns
- list[str]
allowed_file_mime_types(cls) -> list[str]- Return the list of allowed mime types for the artifact.
- Args
cls- Returns
- list[str]
allowed_file_types(cls) -> list[FileOutputType]- Return the list of allowed file output types for the artifact.
- Args
cls- Returns
- list[FileOutputType]
export(self, filename: str | os.PathLike[str] | None = None, overwrite: bool = False) -> Path- Export the artifact to a file
- Args
selffilename(str | os.PathLike[str] | None): Optional absolute (or relative) path to the exported artifact. If omitted the artifact will be written to the current working directory using the artifact id and default export file type extension.overwrite(bool): Whether to overwrite the file if it already exists.- Returns
- Path
from_bytes(cls: type[TArtifact], serialized: bytes, artifact_id: str | None = None) -> TArtifact- Args
cls(type[TArtifact])serialized(bytes)artifact_id(str | None)- Returns
- TArtifact
from_dict(cls: type[TArtifact], data: dict[str, Any], artifact_id: str | None = None) -> TArtifact- Construct an artifact instance from a serialized dictionary.
- Args
cls(type[TArtifact])data(dict[str, Any])artifact_id(str | None)- Returns
- TArtifact
from_json(cls: type[TArtifact], json_str: bytes | str | bytearray, artifact_id: str | None = None) -> TArtifact- Args
cls(type[TArtifact])json_str(bytes | str | bytearray)artifact_id(str | None)- Returns
- TArtifact
from_source_file(cls: type[TArtifact], path: Path, artifact_id: str | None = None) -> TArtifact- Construct an artifact instance from a source file's bytes. This should be based on the artifact type,
- Args
cls(type[TArtifact])path(Path)artifact_id(str | None)- Returns
- TArtifact
get_output_file_name(self, suffix: str | None = None) -> str- Args
selfsuffix(str | None)- Returns
- str
load(cls: type[TArtifact], file_path: str | os.PathLike[str], artifact_id: str | None = None) -> TArtifact- Load an artifact from a file path and return the artifact instance.
- Args
cls(type[TArtifact])file_path(str | os.PathLike[str]): The path to the file to load.artifact_id(str | None): Optional identifier to assign to the loaded artifact.- Returns
- TArtifact: The artifact instance.
read(cls: type[TArtifact], file_path: str | os.PathLike[str], artifact_id: str | None = None) -> TArtifact- Read a file and return its contents based on file type.
- Args
cls(type[TArtifact])file_path(str | os.PathLike[str]): The path to the file to read.artifact_id(str | None): An optional artifact id override. Otherwise, we will use the file name without the extension.- Returns
- TArtifact: The artifact instance.
save(self, file_type: FileOutputType = <FileOutputType.C_STAR_PROTO_BINARY: 'c_star_proto_binary'>, filename: str | os.PathLike[str] | None = None, overwrite: bool = False) -> Path- Persist the spreadsheet to disk
- Args
selffile_type(FileOutputType): The file type to save the artifact as.filename(str | os.PathLike[str] | None): Optional absolute (or relative) path to the output file. If omitted, the artifact is written to the current working directory using the artifact id as the base file name.overwrite(bool): Whether to overwrite the file if it already exists.- Returns
- Path: The path to the written file.
to_bytes(self) -> bytes- Args
self- Returns
- bytes
to_dict(self) -> dict[str, Any]- This should only be used to visualize the artifact as a python dictionary. If you want to serialize the artifact into a file,
- Args
self- Returns
- dict[str, Any]
to_json(self) -> str- Args
self- Returns
- str
to_source_file(self, file_type: FileOutputType, path: Path) -> Path- Serialize the artifact to a source file.
- Args
selffile_type(FileOutputType): The file type to save the artifact as.path(Path): The path to save the artifact to.- Returns
- Path: The path to the written file.
Spreadsheet
CellData
Data of a cell.
SpreadsheetArtifact
Top-level spreadsheet artifact that allows reading, writing, calculation, import and export (to/from xlsx) of a spreadsheet.
allowed_file_types(cls) -> list[FileOutputType]- Args
cls- Returns
- list[FileOutputType]
base_cell_style_format(self, style_index: int) -> CellStyleFormat | None- Look up a cell style format by index.
- Args
selfstyle_index(int): The style index to look up.- Returns
- CellStyleFormat | None: The
CellStyleFormatif present; otherwise None. base_cell_style_formats(self) -> list[CellStyleFormat]- Return all known cell style formats
- Args
self- Returns
- list[CellStyleFormat]: A list of
CellStyleFormat. calculate(self) -> SpreadsheetArtifact- Calculate the spreadsheet.
- Args
self- Returns
- SpreadsheetArtifact
cell_format_summary(self, style_index: int | None) -> CellFormatSummary- Return a denormalized summary for the given style index.
- Args
selfstyle_index(int | None)- Returns
- CellFormatSummary
create_base_cell_style_format(self, text_style: TextStyle | None = None, fill: Fill | None = None, border: Border | None = None, number_format: NumberFormat | None = None) -> int- Create a reusable base cell style format that can be referenced by other cell formats
- Args
selftext_style(TextStyle | None): Optional `TextStyle` componentfill(Fill | None): Optional `Fill` componentborder(Border | None): Optional `Border` componentnumber_format(NumberFormat | None): Optional `NumberFormat`- Returns
- int: The index of the base cell style format. This is what CellFormat.xf_id should point to.
create_cell_format(self, *, source_format_id: int | None = None, merge_with_existing_components: bool = False, fill: Fill | None = None, text_style: TextStyle | None = None, border: Border | None = None, num_format_id: int | None = None, num_format_code: str | None = None, horizontal_alignment: str | None = None, vertical_alignment: str | None = None, apply_protection: bool | None = None, wrap_text: TextWrapOption | None = None, base_cell_style_format_id: int | None = None) -> int- Create a new cell format and return its index (`
cell.style_index`). - Args
selfsource_format_id(int | None): The id of another CellFormat to merge the new format with. If provided, we fetch the cell format and just copy the components and fields provided as a base in the new cell format. The resulting cell format has no reference to this id. This id is what self.create_cell_format returns as the index of the new cell format. This is typically set to be the original style index of the cell if you just want to apply an additional style setting to the cell and not overwrite the existing style completely.merge_with_existing_components(bool): Only applicable ifsource_format_idis provided and not the default style index of 0. If True, this will merge the fields intext_styleandborderinto the existing component that already exists in the format that source_format_id references. If False, this will replace the entire component with the new component provided.fill(Fill | None): Optional `Fillproto (or dict). When provided, a new fill is added to the workbook andfill_id/apply_fill` are updated on the resulting cell format.text_style(TextStyle | None): Optional `TextStyleproto (or dict). When provided, a new font is created andfont_id/apply_font` are set.border(Border | None): Optional `Borderproto (or dict). When provided, a new border is created andborder_id/apply_border` are set.num_format_id(int | None): Optional id of a number format to set on the cell format.num_format_code(str | None): Optional code of a number format to set on the cell format. If provided, we will normalize/create the id and set it on the cell format. If both are provided, num_format_id takes precedence.horizontal_alignment(str | None): Optional horizontal alignment to set on the cell format.vertical_alignment(str | None): Optional vertical alignment to set on the cell format.apply_protection(bool | None): Optional protection to set on the cell format.wrap_text(TextWrapOption | None): Optional wrap text setting to set on the cell format.base_cell_style_format_id(int | None): Id of a base cell format (returned from self.create_base_cell_style_format) that we should inherit the styles from. This sets an actual reference to the base cell format in the cell format proto.- Returns
- int: The index of the newly created cell format.
create_dxf(self, dxf: DifferentialFormat) -> int- Create a new differential format and return its index.
- Args
selfdxf(DifferentialFormat): TheDifferentialFormatto add to the workbook styles.- Returns
- int
create_sheet(self, name: str) -> SpreadsheetSheet- Create a new sheet and return its wrapper.
- Args
selfname(str): The name of the new sheet.- Returns
- SpreadsheetSheet: The created
SpreadsheetSheet, or None if a sheet with the same name already exists. delete_sheet(self, name: str | None = None, idx: int | None = None) -> None- Delete a sheet by name or index.
- Args
selfname(str | None)idx(int | None)- Returns
- None
export(self, filename: str | os.PathLike[str] | None = None, overwrite: bool = False) -> Path- Export the workbook to XLSX format.
- Args
selffilename(str | os.PathLike[str] | None)overwrite(bool)- Returns
- Path
from_bytes(cls, serialized: bytes, artifact_id: str | None = None) -> SpreadsheetArtifact- Create an artifact from a serialized
Workbookbyte string. - Args
clsserialized(bytes): A serializedWorkbookproto as bytes.artifact_id(str | None)- Returns
- SpreadsheetArtifact: A new
SpreadsheetArtifactinstance. from_dict(cls, data: dict[str, Any], artifact_id: str | None = None) -> SpreadsheetArtifact- Create an artifact from a dict representation.
- Args
clsdata(dict[str, Any]): A dict compatible withWorkbookwhen parsed viaParseDict.artifact_id(str | None)- Returns
- SpreadsheetArtifact: A new
SpreadsheetArtifactinstance. from_json(cls, json_str: str | bytes | bytearray, artifact_id: str | None = None) -> SpreadsheetArtifact- Args
clsjson_str(str | bytes | bytearray)artifact_id(str | None)- Returns
- SpreadsheetArtifact
from_source_file(cls, path: Path, artifact_id: str | None = None) -> SpreadsheetArtifact- Construct an artifact from an Excel file on disk using the Granola CLI.
- Args
clspath(Path)artifact_id(str | None)- Returns
- SpreadsheetArtifact
get_border_by_id(self, border_id: int) -> Border | None- Get a border by index.
- Args
selfborder_id(int)- Returns
- Border | None
get_cell_format(self, style_index: int) -> CellFormat | None- Get a cell format by index.
- Args
selfstyle_index(int)- Returns
- CellFormat | None
get_dxf(self, dxf_id: int) -> DifferentialFormat | None- Get a differential format by index.
- Args
selfdxf_id(int): The index of the differential format to look up if it exists.- Returns
- DifferentialFormat | None
get_fill_by_id(self, fill_id: int) -> Fill | None- Get a fill by index.
- Args
selffill_id(int)- Returns
- Fill | None
get_number_format_by_id(self, number_format_id: int) -> NumberFormat | None- Get a number format by index.
- Args
selfnumber_format_id(int)- Returns
- NumberFormat | None
get_sheet(self, name: str | None = None, idx: int | None = None) -> SpreadsheetSheet | None- Returns a sheet wrapper by name or index if the sheet exists.
- Args
selfname(str | None): The sheet name.idx(int | None): The position of the sheet in the workbook.- Returns
- SpreadsheetSheet | None: The
SpreadsheetSheetif present; otherwise None. get_text_style_by_id(self, text_style_id: int) -> TextStyle | None- Get a font by index.
- Args
selftext_style_id(int)- Returns
- TextStyle | None
recalculate(self) -> SpreadsheetArtifact- Recalculate the spreadsheet - same as calculate()
- Args
self- Returns
- SpreadsheetArtifact
rename_sheet(self, *, new_name: str, sheet_idx: int | None = None, old_name: str | None = None) -> SpreadsheetSheet- Set a sheet's name to
new_name. - Args
selfnew_name(str): The new name of the sheet.sheet_idx(int | None): The position of the sheet in the workbook (0-indexed)old_name(str | None): The old name of the sheet to set the name of. If provided, will use the sheet with this name.- Returns
- SpreadsheetSheet: The
SpreadsheetSheetwith the new name. render(self, output: os.PathLike[str] | str | None = None, *, sheet_name: str | None = None, cell_range: str | None = None, center: str | None = None, width: int | None = None, height: int | None = None, include_headers: bool = True, scale: float = 1.0, performance: bool = False) -> tuple[Path, ...]- Render the spreadsheet via the Granola CLI and return the output files.
- Args
selfoutput(os.PathLike[str] | str | None)sheet_name(str | None)cell_range(str | None)center(str | None)width(int | None)height(int | None)include_headers(bool)scale(float)performance(bool)- Returns
- tuple[Path, ...]
sheet(self, name: str) -> SpreadsheetSheet- Get a sheet wrapper by name.
- Args
selfname(str): The sheet name.- Returns
- SpreadsheetSheet: The
SpreadsheetSheetif present; otherwise None. sheets(self) -> list[str]- Return all sheet names.
- Args
self- Returns
- list[str]
summary(self) -> SpreadsheetSummary- Return a summary of the spreadsheet.
- Args
self- Returns
- SpreadsheetSummary
to_bytes(self) -> bytes- Serialize the workbook to bytes.
- Args
self- Returns
- bytes: The serialized
Workbookbytes. to_dict(self) -> dict[str, Any]- Convert the workbook to a JSON-serializable dict.
- Args
self- Returns
- dict[str, Any]: A dict produced by
MessageToDictwith proto field names preserved. to_json(self) -> str- Convert the workbook to a JSON-serializable string.
- Args
self- Returns
- str: A JSON-serializable string.
to_source_file(self, file_type: FileOutputType, path: Path) -> Path- Serialize the workbook to a file supported by Granola.
- Args
selffile_type(FileOutputType)path(Path)- Returns
- Path
allowed_file_extensions(cls) -> list[str]- Return the list of allowed file extensions for the artifact.
- Args
cls- Returns
- list[str]
allowed_file_mime_types(cls) -> list[str]- Return the list of allowed mime types for the artifact.
- Args
cls- Returns
- list[str]
get_output_file_name(self, suffix: str | None = None) -> str- Args
selfsuffix(str | None)- Returns
- str
load(cls: type[TArtifact], file_path: str | os.PathLike[str], artifact_id: str | None = None) -> TArtifact- Load an artifact from a file path and return the artifact instance.
- Args
cls(type[TArtifact])file_path(str | os.PathLike[str]): The path to the file to load.artifact_id(str | None): Optional identifier to assign to the loaded artifact.- Returns
- TArtifact: The artifact instance.
read(cls: type[TArtifact], file_path: str | os.PathLike[str], artifact_id: str | None = None) -> TArtifact- Read a file and return its contents based on file type.
- Args
cls(type[TArtifact])file_path(str | os.PathLike[str]): The path to the file to read.artifact_id(str | None): An optional artifact id override. Otherwise, we will use the file name without the extension.- Returns
- TArtifact: The artifact instance.
save(self, file_type: FileOutputType = <FileOutputType.C_STAR_PROTO_BINARY: 'c_star_proto_binary'>, filename: str | os.PathLike[str] | None = None, overwrite: bool = False) -> Path- Persist the spreadsheet to disk
- Args
selffile_type(FileOutputType): The file type to save the artifact as.filename(str | os.PathLike[str] | None): Optional absolute (or relative) path to the output file. If omitted, the artifact is written to the current working directory using the artifact id as the base file name.overwrite(bool): Whether to overwrite the file if it already exists.- Returns
- Path: The path to the written file.
SpreadsheetCellRangeRef
High-level reference over a rectangular range in a SpreadsheetSheet.
conditional_formats(ConditionalFormatCollection)- Get a ConditionalFormatCollection object for this range.
- Returns
- A ConditionalFormatCollection object that can be used to read and set conditional formats onto the range.
format(RangeFormat)- Get a RangeFormat object for this range.
- Returns
- A RangeFormat object that can be used to read and set styles onto the range.
formulas(list[list[str | None]])- Get the formulas of the cells in this range. None means cell formula is not set.
- Returns
- A 2D sequence of formulas matching the shape of the range. None means cell formula is not set. Note: All cells in a merged cell will have the same formula. Example: [ [ None, None, "=G109G110" ], [ None, None, "=G108G110" ], [ None, None, "=G107*G110" ] ]
style_indices(list[list[int]])- Return a 2D list of style indices for this range.
- Returns
- A matrix of integers (style indices) or None for missing cells. Note: 0 is the default style index for cells e.g. [ [ 10, 12, 14 ], [ 10, 12, 14 ], [ 10, 0, 10 ] ]
values(list[list[SpreadsheetCellValueType]])- Get the values of the cells in this range. None means cell value is not set.
- Returns
- A 2D sequence of values matching the shape of the range. None means cell value is not set. Note: All cells in a merged cell will have the same value.
data(self) -> list[list[SpreadsheetCellValueType | str | None]]- Get the data for the range.
- Args
self- Returns
- list[list[SpreadsheetCellValueType | str | None]]
merge(self, raise_on_conflict: bool = False) -> SpreadsheetCellRangeRef- Merge the cells in the range.
- Args
selfraise_on_conflict(bool)- Returns
- SpreadsheetCellRangeRef
unmerge(self) -> SpreadsheetCellRangeRef- Unmerge the cells in the range.
- Args
self- Returns
- SpreadsheetCellRangeRef
cite(self: VR, *, tether_id: str, start_line_number: int | None = None, end_line_number: int | None = None, content_reference_type: ContentReferenceType = 2, source_type: SourceType = 1) -> VR- Attach citations and annotate the target cell as a Note.
- Args
self(VR)tether_id(str): Convenience parameter to create aContentReferencewith the given tether id. When provided, line range metadata can also be supplied without manually instantiating a proto.start_line_number(int | None): Optional line number where the cite begins.end_line_number(int | None): Optional line number where the cite ends.content_reference_type(ContentReferenceType): Classification of the referenced content. Defaults toCONTENT_REFERENCE_TYPE_EXTERNAL.source_type(SourceType): Source classification of the reference (for example, webpage, image, or file). Defaults toSOURCE_TYPE_WEBPAGE.- Returns
- VR: self (for method chaining)
get_data(self) -> list[list[SpreadsheetCellValueType | str | None]]- Return a 2D list of cell data for this range.
- Args
self- Returns
- list[list[SpreadsheetCellValueType | str | None]]: A matrix of cell data or None for missing cells. For formulas, the formula will be returned. For cells with no formulas but has a value, the value will be returned.
get_formulas(self) -> list[list[str | None]]- Same as .formulas()
- Args
self- Returns
- list[list[str | None]]
get_values(self) -> list[list[SpreadsheetCellValueType]]- Same as .values()
- Args
self- Returns
- list[list[SpreadsheetCellValueType]]
has_merged_cells(self) -> bool- Returns True if this range contains any merged cells.
- Args
self- Returns
- bool
is_merged_cell(self) -> bool- Returns True if this range is a single merged cell.
- Args
self- Returns
- bool
is_single_cell(self) -> bool- Returns True if this range is a single cell.
- Args
self- Returns
- bool
is_single_column(self) -> bool- Returns True if this range is a column.
- Args
self- Returns
- bool
is_single_row(self) -> bool- Returns True if this range is a row.
- Args
self- Returns
- bool
render(self, output: os.PathLike[str] | str | None = None, *, include_headers: bool = True, scale: float = 1.0, performance: bool = False) -> Path- Render this range via the parent sheet.
- Args
selfoutput(os.PathLike[str] | str | None)include_headers(bool)scale(float)performance(bool)- Returns
- Path
set_formula(self: VR, formula: str, *, recalculate: bool = True) -> VR- Set all cells in the range to the given formula.
- Args
self(VR)formula(str): The formula to set. The formula must be a valid formula string, e.g. "=A1*B1" or "". Using "" clears the cell's formula.recalculate(bool): Whether to recalculate the spreadsheet after setting the value.allow_partial_merge_cells: Whether to allow setting the value if the range is part of a merged cell.- Returns
- VR: self (for method chaining)
set_formulas(self: VR, formulas_matrix: Sequence[Sequence[str]]) -> VR- Set the formulas of the cells in this range.
- Args
self(VR)formulas_matrix(Sequence[Sequence[str]])formulas: A 2D sequence of formulas matching the shape of the range. Each item must be a valid formula string, e.g. "=A1*B1" or "". Using "" clears the cell's formula.- Returns
- VR: self
set_rich_text(self: VR, rich_text: RichTextInput, *, recalculate: bool = True, overwrite_existing: bool = True) -> VR- Set the cell(s) to inline rich text composed of TextRuns.
- Args
self(VR)rich_text(RichTextInput): Either a sequence of run specs for single-cell ranges or a matrix (rows x columns) of run spec sequences matching the range. Example: [{"t": "some "}, {"t": "italic ", "i": True}]recalculate(bool): Whether to trigger a recalculation after writing the runs.overwrite_existing(bool): Whether to overwrite the existing cell proto, as opposed to merging fields. Defaults to True since rich text typically replaces existing content entirely.- Returns
- VR: self
set_style_index(self: VR, style_index: int) -> VR- Set a uniform style index for all cells in the range.
- Args
self(VR)style_index(int): The style index to assign to each cell in the range.- Returns
- VR
set_value(self: VR, value: SpreadsheetCellValueType, *, recalculate: bool = True) -> VR- Set all cells in the range to the given value.
- Args
self(VR)value(SpreadsheetCellValueType): The value to set. The type ofvalueindicates the data type of the cell. For example, value=5 meeans the cell is a number and the value is 5. but value="5" means the cell is a string and the value is the string "5".recalculate(bool): Whether to recalculate the spreadsheet after setting the value.- Returns
- VR: self (for method chaining)
set_values(self: VR, values_matrix: Sequence[Sequence[SpreadsheetCellValueType]]) -> VR- Set the values of the range to the given values_matrix.
- Args
self(VR)values_matrix(Sequence[Sequence[SpreadsheetCellValueType]])raw_cells_matrix: A 2D matrix matching the range. None clears the cell's value.- Returns
- VR: self
SpreadsheetCellRef
High-level reference over a cell a SpreadsheetSheet
data(SpreadsheetCellValueType | str | None)- Returns the data of the cell
formula(str | None)- Get the cell's formula string.
- Returns
- The cell's formula (e.g., "=A1*B1") or None if the formula is not set.
style_index(int)- Get the cell's style index. 0 is the default style index.
value(SpreadsheetCellValueType)- Get the cell's value if it exists.
conditional_formats(ConditionalFormatCollection)- Get a ConditionalFormatCollection object for this range.
- Returns
- A ConditionalFormatCollection object that can be used to read and set conditional formats onto the range.
format(RangeFormat)- Get a RangeFormat object for this range.
- Returns
- A RangeFormat object that can be used to read and set styles onto the range.
formulas(list[list[str | None]])- Get the formulas of the cells in this range. None means cell formula is not set.
- Returns
- A 2D sequence of formulas matching the shape of the range. None means cell formula is not set. Note: All cells in a merged cell will have the same formula. Example: [ [ None, None, "=G109G110" ], [ None, None, "=G108G110" ], [ None, None, "=G107*G110" ] ]
style_indices(list[list[int]])- Return a 2D list of style indices for this range.
- Returns
- A matrix of integers (style indices) or None for missing cells. Note: 0 is the default style index for cells e.g. [ [ 10, 12, 14 ], [ 10, 12, 14 ], [ 10, 0, 10 ] ]
values(list[list[SpreadsheetCellValueType]])- Get the values of the cells in this range. None means cell value is not set.
- Returns
- A 2D sequence of values matching the shape of the range. None means cell value is not set. Note: All cells in a merged cell will have the same value.
format_summary(self) -> CellFormatSummary- Return a denormalized summary of the cell's style.
- Args
self- Returns
- CellFormatSummary
get_calculation_error_message(self) -> str | None- Returns the calculation error message if the cell's value indicates a calculation error.
- Args
self- Returns
- str | None
is_calculation_error(self) -> bool- Returns True if the cell's value indicates a calculation error.
- Args
self- Returns
- bool
to_dict(self) -> dict[str, object]- Return a dictionary representation of the cell as the Cell proto.
- Args
self- Returns
- dict[str, object]
cite(self: VR, *, tether_id: str, start_line_number: int | None = None, end_line_number: int | None = None, content_reference_type: ContentReferenceType = 2, source_type: SourceType = 1) -> VR- Attach citations and annotate the target cell as a Note.
- Args
self(VR)tether_id(str): Convenience parameter to create aContentReferencewith the given tether id. When provided, line range metadata can also be supplied without manually instantiating a proto.start_line_number(int | None): Optional line number where the cite begins.end_line_number(int | None): Optional line number where the cite ends.content_reference_type(ContentReferenceType): Classification of the referenced content. Defaults toCONTENT_REFERENCE_TYPE_EXTERNAL.source_type(SourceType): Source classification of the reference (for example, webpage, image, or file). Defaults toSOURCE_TYPE_WEBPAGE.- Returns
- VR: self (for method chaining)
get_data(self) -> list[list[SpreadsheetCellValueType | str | None]]- Return a 2D list of cell data for this range.
- Args
self- Returns
- list[list[SpreadsheetCellValueType | str | None]]: A matrix of cell data or None for missing cells. For formulas, the formula will be returned. For cells with no formulas but has a value, the value will be returned.
get_formulas(self) -> list[list[str | None]]- Same as .formulas()
- Args
self- Returns
- list[list[str | None]]
get_values(self) -> list[list[SpreadsheetCellValueType]]- Same as .values()
- Args
self- Returns
- list[list[SpreadsheetCellValueType]]
has_merged_cells(self) -> bool- Returns True if this range contains any merged cells.
- Args
self- Returns
- bool
is_merged_cell(self) -> bool- Returns True if this range is a single merged cell.
- Args
self- Returns
- bool
is_single_cell(self) -> bool- Returns True if this range is a single cell.
- Args
self- Returns
- bool
is_single_column(self) -> bool- Returns True if this range is a column.
- Args
self- Returns
- bool
is_single_row(self) -> bool- Returns True if this range is a row.
- Args
self- Returns
- bool
render(self, output: os.PathLike[str] | str | None = None, *, include_headers: bool = True, scale: float = 1.0, performance: bool = False) -> Path- Render this range via the parent sheet.
- Args
selfoutput(os.PathLike[str] | str | None)include_headers(bool)scale(float)performance(bool)- Returns
- Path
set_formula(self: VR, formula: str, *, recalculate: bool = True) -> VR- Set all cells in the range to the given formula.
- Args
self(VR)formula(str): The formula to set. The formula must be a valid formula string, e.g. "=A1*B1" or "". Using "" clears the cell's formula.recalculate(bool): Whether to recalculate the spreadsheet after setting the value.allow_partial_merge_cells: Whether to allow setting the value if the range is part of a merged cell.- Returns
- VR: self (for method chaining)
set_formulas(self: VR, formulas_matrix: Sequence[Sequence[str]]) -> VR- Set the formulas of the cells in this range.
- Args
self(VR)formulas_matrix(Sequence[Sequence[str]])formulas: A 2D sequence of formulas matching the shape of the range. Each item must be a valid formula string, e.g. "=A1*B1" or "". Using "" clears the cell's formula.- Returns
- VR: self
set_rich_text(self: VR, rich_text: RichTextInput, *, recalculate: bool = True, overwrite_existing: bool = True) -> VR- Set the cell(s) to inline rich text composed of TextRuns.
- Args
self(VR)rich_text(RichTextInput): Either a sequence of run specs for single-cell ranges or a matrix (rows x columns) of run spec sequences matching the range. Example: [{"t": "some "}, {"t": "italic ", "i": True}]recalculate(bool): Whether to trigger a recalculation after writing the runs.overwrite_existing(bool): Whether to overwrite the existing cell proto, as opposed to merging fields. Defaults to True since rich text typically replaces existing content entirely.- Returns
- VR: self
set_style_index(self: VR, style_index: int) -> VR- Set a uniform style index for all cells in the range.
- Args
self(VR)style_index(int): The style index to assign to each cell in the range.- Returns
- VR
set_value(self: VR, value: SpreadsheetCellValueType, *, recalculate: bool = True) -> VR- Set all cells in the range to the given value.
- Args
self(VR)value(SpreadsheetCellValueType): The value to set. The type ofvalueindicates the data type of the cell. For example, value=5 meeans the cell is a number and the value is 5. but value="5" means the cell is a string and the value is the string "5".recalculate(bool): Whether to recalculate the spreadsheet after setting the value.- Returns
- VR: self (for method chaining)
set_values(self: VR, values_matrix: Sequence[Sequence[SpreadsheetCellValueType]]) -> VR- Set the values of the range to the given values_matrix.
- Args
self(VR)values_matrix(Sequence[Sequence[SpreadsheetCellValueType]])raw_cells_matrix: A 2D matrix matching the range. None clears the cell's value.- Returns
- VR: self
SpreadsheetSheet
A spreadsheet sheet class to allow reading and writing to a single sheet in a spreadsheet.
charts(SpreadsheetSheetCharts)- Return the charts in the sheet.
default_col_width(float | None)- Get the default column width for the sheet.
default_row_height(float | None)- Get the default row height for the sheet.
filled_columns(int)- Returns the number of columns in the sheet that actually have cells.
filled_rows(int)- Returns the number of rows in the sheet that actually have cells.
name(str)- Return the sheet's name.
show_grid_lines(bool)- Get the show grid lines for the sheet.
add_table(self, ref: str, *, has_headers: bool = True, name: str | None = None, display_name: str | None = None, style_name: str | None = None, totals_row_count: int = 0) -> SpreadsheetTable- Add a new table to this sheet.
- Args
selfref(str): A1 range for the full table (including header and totals if present).has_headers(bool): Whether the first row is a header row.name(str | None): Optional internal name for the table; defaults to "Table{n}".display_name(str | None): Optional display name; defaults to `name`.style_name(str | None): Optional style name assigned to the table.totals_row_count(int): Number of totals rows at the bottom (0 or 1 typical).- Returns
- SpreadsheetTable: SpreadsheetTable wrapper for the created table.
cell(self, address: str) -> SpreadsheetCellRef- Return a cell by address.
- Args
selfaddress(str): An A1-style address (e.g., "C5")- Returns
- SpreadsheetCellRef
cleanup_and_validate_sheet(self) -> None- Cleanup and validate the sheet.
- Args
self- Returns
- None
clear_cells(self, address: str, fields_to_clear: list[str] | None = None, *, recalculate: bool = True) -> SpreadsheetSheet- Clear the values and formulas for the cells in the range.
- Args
selfaddress(str): The address range to clear the cells from, e.g. "A1" or "A1:B2"fields_to_clear(list[str] | None): The fields to clear.recalculate(bool): Whether to recalculate the range after clearing the fields.- Returns
- SpreadsheetSheet: self (for method chaining)
create_conditional_formatting(self, conditional_formatting: ConditionalFormatting | dict[str, Any] | None = None, *, ranges: list[str] | None = None, rules: list[CfRule] | list[dict[str, Any]] | None = None, style: DifferentialFormat | None = None) -> ConditionalFormatting- Attach a conditional formatting block to the sheet.
- Args
selfconditional_formatting(ConditionalFormatting | dict[str, Any] | None): OptionalConditionalFormattingproto or dict representation to seed the entry. Additionalrangesandrulesarguments extend (rather than replace) the proto. If conditional_formatting is not provided, both ranges, rules, and style must be provided.ranges(list[str] | None): Iterable of A1-style ranges (e.g. "A1:C3") to associate with the conditional formatting. Sheet metadata is filled in automatically.rules(list[CfRule] | list[dict[str, Any]] | None): Iterable of :class:CfRuleprotos or dict representations. Note: We do not require a dxf_id if style is provided. Note: If dxf_id is provided, a corresponding style must exist in the style proto. Recommended to leave dxf_id as empty and pass in the style instead, which will create a new style.style(DifferentialFormat | None): OptionalDifferentialFormatproto to set as the style for the conditional formatting. If provided, this creates a new differntial format style and adds it to the style proto.- Returns
- ConditionalFormatting: `
self` to allow fluent-style chaining. data(self, address: str) -> SpreadsheetCellValueType | str | None- Get the cell's data or None if the cell does not exist or data is empty.
- Args
selfaddress(str): The address of a single cell to get the data from.- Returns
- SpreadsheetCellValueType | str | None: The cell's data is either the formula if it exists, otherwise the value.
data_by_indices(self, col_idx: int, row_idx: int) -> SpreadsheetCellValueType | str | None- Same as data but by indices.
- Args
selfcol_idx(int)row_idx(int)- Returns
- SpreadsheetCellValueType | str | None
delete_conditional_formatting(self, cf: ConditionalFormatting) -> SpreadsheetSheet- Delete a conditional formatting from the sheet if one exists that is equal to the provided proto.
- Args
selfcf(ConditionalFormatting)- Returns
- SpreadsheetSheet
delete_table(self, name_or_id: str | int) -> None- Delete a table by name/display name or id.
- Args
selfname_or_id(str | int): The tablename/display_namestring or numeric id.- Returns
- None
exists(self, address: str | tuple[int, int]) -> bool- Check if a cell by address exists.
- Args
selfaddress(str | tuple[int, int]): An A1-style address (e.g., "C5") or a tuple of (column index, row index).- Returns
- bool
formula(self, address: str) -> str | None- Get the formula of a cell by address. Empty string means the formula is empty.
- Args
selfaddress(str)- Returns
- str | None
get_cell_field(self, address: str, field_name: str, default_if_present: Any | None = None) -> Any | None- Generic method to get any field on the cell by address or returns None if the cell does not exist.
- Args
selfaddress(str)field_name(str)default_if_present(Any | None)- Returns
- Any | None
get_cell_field_by_indices(self, col_idx: int, row_idx: int, field_name: str, default_if_present: Any | None = None) -> Any | None- Generic method to get any field on the cell by indices or returns None if the cell does not exist.
- Args
selfcol_idx(int)row_idx(int)field_name(str)default_if_present(Any | None)- Returns
- Any | None
get_column_width(self, address: str) -> float | None- Get the width of a column if it's defined by the user.
- Args
selfaddress(str)- Returns
- float | None
get_conditional_formatting(self) -> list[ConditionalFormatting]- Return a copy of the sheet's conditional formatting definitions.
- Args
self- Returns
- list[ConditionalFormatting]
get_effective_cell(self, address: str) -> SpreadsheetCellRef- Return the effective cell by address.
- Args
selfaddress(str): An A1-style address (e.g., "C5")- Returns
- SpreadsheetCellRef
get_first_row_address_range(self) -> str | None- Return the address range of the first row in the sheet.
- Args
self- Returns
- str | None
get_max_column_letter(self) -> str | None- Return the letter of the last column in the sheet.
- Args
self- Returns
- str | None
get_min_column_letter(self) -> str | None- Return the letter of the first column in the sheet.
- Args
self- Returns
- str | None
get_raw_cell_proto(self, address: str, reference: bool = False) -> Cell | None- Get a cell by address as a proto if it exists, otherwise returns None.
- Args
selfaddress(str): The address of the cell to get as a proto.reference(bool): Whether to return a reference to the cell proto or a copy.- Returns
- Cell | None
get_table(self, name: str | None = None, id: int | None = None) -> SpreadsheetTable | None- Get a table by name/display name or id.
- Args
selfname(str | None): Tablenameordisplay_nameto match.id(int | None): Table id to match (1-based).- Returns
- SpreadsheetTable | None: The matching
SpreadsheetTableif found, otherwise None. has_merged_cells(self, address_range: str) -> bool- Check if the address range contains merged cells.
- Args
selfaddress_range(str)- Returns
- bool
is_calculation_error(self, address: str) -> bool- Check if the cell is a calculation error.
- Args
selfaddress(str)- Returns
- bool
is_empty(self) -> bool- Return True if the sheet is empty.
- Args
self- Returns
- bool
is_merged_cell(self, address_range: str) -> bool- Returns True if the range is a single merged cell.
- Args
selfaddress_range(str)- Returns
- bool
merge_cells(self, address_range: str, raise_on_conflict: bool = False) -> SpreadsheetSheet- Merge cells in the sheet. By doing this, the cells will be treated as a single cell and
- Args
selfaddress_range(str): The address range to merge.raise_on_conflict(bool): Whether to raise an error if there are multiple cells in the range with values.- Returns
- SpreadsheetSheet
minimum_address_range_filled(self) -> str- Return the minimum address range that is filled in the sheet.
- Args
self- Returns
- str
minimum_range(self) -> SpreadsheetCellRangeRef- Return the minimum range that is filled in the sheet.
- Args
self- Returns
- SpreadsheetCellRangeRef
range(self, address_range: str) -> SpreadsheetCellRangeRef- Return a range by address_range for an A1-style address range.
- Args
selfaddress_range(str): An A1-style range such as "A1:C10".- Returns
- SpreadsheetCellRangeRef
recalculate(self, address: str | None = None) -> None- Recalculate the spreadsheet
- Args
selfaddress(str | None): The address of the cell to recalculate.- Returns
- None
rename(self, new_name: str) -> SpreadsheetSheet- Rename the sheet.
- Args
selfnew_name(str)- Returns
- SpreadsheetSheet
render(self, output: os.PathLike[str] | str | None = None, *, cell_range: str | None = None, center: str | None = None, width: int | None = None, height: int | None = None, include_headers: bool = True, scale: float = 1.0, performance: bool = False) -> Path- Render this sheet to images or JSON via the Granola CLI.
- Args
selfoutput(os.PathLike[str] | str | None)cell_range(str | None)center(str | None)width(int | None)height(int | None)include_headers(bool)scale(float)performance(bool)- Returns
- Path
set_cell_formulas_to(self, address: str, formula: str, *, recalculate: bool = True) -> SpreadsheetSheet- Sets the value for all cells in the range to the same value.
- Args
selfaddress(str): The address of the cells to set the value for.formula(str): Sets the formula for all cells in the range to the same formula. Empty string clears the formula.recalculate(bool): Whether to recalculate the cells after setting the value.- Returns
- SpreadsheetSheet
set_cell_values_to(self, address: str, value: SpreadsheetCellValueType, *, recalculate: bool = True) -> SpreadsheetSheet- Sets the value for all cells in the range to the same value.
- Args
selfaddress(str): The address of the cells to set the value for.value(SpreadsheetCellValueType): The value to set the cells to. None clears the cell's value.recalculate(bool): Whether to recalculate the cells after setting the value.- Returns
- SpreadsheetSheet
set_column_widths(self, address_reference: str, width: float) -> SpreadsheetSheet- Set the column widths for a range of columns to be the same width.
- Args
selfaddress_reference(str): Excel-style column reference (e.g. "B" or "C:F").width(float): The column width to assign.- Returns
- SpreadsheetSheet: `
self` to allow fluent-style chaining. set_column_widths_bulk(self, address_reference_to_widths: dict[str, float]) -> SpreadsheetSheet- Set the column widths for different column ranges to be the widths specified in the dictionary.
- Args
selfaddress_reference_to_widths(dict[str, float]): A dictionary of address references to column widths.Example: {"B:D": 100, "F": 150}- Returns
- SpreadsheetSheet: `
self` to allow fluent-style chaining. set_row_height(self, row_index: int, height: float | None) -> SpreadsheetSheet- Set or clear the height for a specific row.
- Args
selfrow_index(int): 1-based row index to update.height(float | None): Desired row height. Provide `None` to clear the custom height.- Returns
- SpreadsheetSheet
set_row_heights(self, start_row_index: int, end_row_index: int, height: float | None) -> SpreadsheetSheet- Set the height for a range of rows.
- Args
selfstart_row_index(int)end_row_index(int)height(float | None)- Returns
- SpreadsheetSheet
set_row_heights_bulk(self, row_index_to_heights: dict[int, float]) -> SpreadsheetSheet- Set the heights for a range of rows to be the heights specified in the dictionary.
- Args
selfrow_index_to_heights(dict[int, float]): A dictionary of row indices to row heights.- Returns
- SpreadsheetSheet: `
self` to allow fluent-style chaining. set_sheet_styles(self, default_row_height: float | None = None, default_col_width: float | None = None, show_grid_lines: bool | None = None) -> SpreadsheetSheet- Alter the styles for the sheet for non-None values.
- Args
selfdefault_row_height(float | None)default_col_width(float | None)show_grid_lines(bool | None)- Returns
- SpreadsheetSheet
set_style_index(self, address: str, style_index: int) -> SpreadsheetSheet- Set the style index of a cell by address.
- Args
selfaddress(str): The address of the cell to set the style index for.style_index(int): The style index to set. This is the index to a CellFormat in the workbook.styles.cell_xfs.- Returns
- SpreadsheetSheet: self
style_index(self, address: str) -> int | None- Get the style index of a cell by address.
- Args
selfaddress(str)- Returns
- int | None
summary(self) -> SpreadsheetSheetSummary- Return a summary of the sheet.
- Args
self- Returns
- SpreadsheetSheetSummary
tables(self) -> list[SpreadsheetTable]- Return all tables on this sheet as wrapper objects.
- Args
self- Returns
- list[SpreadsheetTable]: A list of
SpreadsheetTablewrappers in sheet order. to_dict(self) -> dict[str, Any]- Return the spreadsheet as a dictionary.
- Args
self- Returns
- dict[str, Any]
unmerge_cells(self, address_range: str) -> SpreadsheetSheet- Unmerge cells in the sheet. Only an existing merged cell range can be unmerged.
- Args
selfaddress_range(str)- Returns
- SpreadsheetSheet
value(self, address: str) -> SpreadsheetCellValueType- Get the value of a cell by address.
- Args
selfaddress(str)- Returns
- SpreadsheetCellValueType
values(self, address: str) -> list[list[SpreadsheetCellValueType]]- Get the parsed values of the cells in the range. None means cell value is not set.
- Args
selfaddress(str)- Returns
- list[list[SpreadsheetCellValueType]]
SpreadsheetSheetSummary
Summary of a spreadsheet sheet.
to_dict(self) -> dict[str, object]- Return a JSON-safe representation for convenience.
- Args
self- Returns
- dict[str, object]
SpreadsheetStyleIndices
SpreadsheetStyleIndices(text_style_id: 'int | None' = None, fill_id: 'int | None' = None, border_id: 'int | None' = None, number_format_id: 'int | None' = None, cell_style_format_id: 'int | None' = None, cell_format_id: 'int | None' = None, cell_style_id: 'int | None' = None)
is_empty(self) -> bool- Args
self- Returns
- bool
SpreadsheetSummary
Summary of a spreadsheet
to_dict(self) -> dict[str, object]- Return a JSON-safe representation for convenience.
- Args
self- Returns
- dict[str, object]
Spreadsheet Calculations
We support calculating most common Excel spreadsheet functions, but not all. However, even if unsupported, the formula (if it's officially supported by Excel) can still be stored and exported to XLSX.
When you set a cell's formula to a value that is not supported by the engine, but is a valid Excel formula, the cell's value will be set to the error message (e.g. "#NAME?"), which indicates the formula function is not supported. Upon export to XLSX and opening in Excel, the cell properly calculates.
To see the full list of supported functions for calculations, see: artifact_tool_spreadsheet_formulas.md
To check on if there's a calculation error:
- SpreadsheetCellRef.is_calculation_error() to check if the cell's value is an error.
- SpreadsheetCellRef.get_calculation_error_message() to get the error message if it is an error.
If the cell's value is NOT a calculation error, the value will be the result of the formula post-calculation, unless the cell was set with recalculate=False
Example: sheet.set_cell(address, value, recalculate=False).
"""Example: create a new spreadsheet, add a sheet, set cells, read ranges."""
# ruff: noqa: I001
from __future__ import annotations
from pprint import pprint
from artifact_tool import SpreadsheetArtifact
import logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
)
def main() -> None:
# Create a new spreadsheet artifact
spreadsheet = SpreadsheetArtifact("AwesomeCompany")
# Look at what exists
spreadsheet.get_sheet("Overview") # None
overviews_sheet = spreadsheet.create_sheet("Overview")
employees_sheet = spreadsheet.create_sheet("Employees")
overviews_sheet.cell("A1").value = "Description"
overviews_sheet.cell("A2").value = "Awesome Company Report"
# Write headers with the range helper
employees_sheet.range("A1:D1").set_values([["Title", "Name", "Address", "Score"]]) # row 1
employees_sheet.range("A2:D4").set_values(
[
["Engineer", "Vicky", "90 50th Street", 98], # row 2
["Manager", "Alex", "500 Market Street", 92], # row 3
["Designer", "Jordan", "200 Pine Street", 88], # row 4
]
)
print("\nCreating a basic spreadsheet template with the following structure:")
pprint(spreadsheet.to_dict())
print("Adding a total scores row with a sum formula")
# Skip a line and add a sum formula cell
employees_sheet.cell("A6").set_value("Total Score")
employees_sheet.cell("D6").formula = "=SUM(D2:D4)"
assert employees_sheet.formula("D6") == "=SUM(D2:D4)"
assert employees_sheet.cell("D6").data == "=SUM(D2:D4)"
employees_sheet.recalculate()
assert employees_sheet.cell("D6").value == 278
assert employees_sheet.cell("D6").data == "=SUM(D2:D4)"
# Edit with the bracket shortcut
print("Updating Vicky's title to Standing Desk Operator")
employees_sheet.cell("A2").value = "Standing Desk Operator"
print("Updating Alex's name to Alex V2 and address to [private] address")
employees_sheet.range("B3:C3").values = [["Alex V2", "[private] address"]]
# Add a new column for promotions
print("Adding a new column for promotions")
employees_sheet.range("E1:E4").set_values([["Promotion"], [True], [False], [True]])
# Make sure vicky is getting a promption
assert employees_sheet.value("E2") is True
assert employees_sheet.cell("E2").value is True
# Read what you made
print("\n==Overview sheet (raw data):")
pprint(overviews_sheet.range("A1:E4").get_data())
print("\n==Scores sheet (raw data):")
pprint(employees_sheet.range("A1:E6").get_data())
print("\n==Scores sheet (values):")
pprint(employees_sheet.range("A1:E6").values)
print("\n==Scores sheet as a dictionary:")
pprint(employees_sheet.to_dict())
print("\n==Serialized workbook dictionary:")
pprint(spreadsheet.to_dict())
print("\n==Serialized workbook length:")
pprint(len(spreadsheet.to_json()))
# Render the final spreadsheet
render_path = spreadsheet.render()
print(f"Rendered spreadsheet to {render_path}")
# Saves it to binary format in the current directory
proto_path = spreadsheet.save()
print(f"Saved spreadsheet proto to {proto_path}")
export_path = spreadsheet.export()
print(f"Exported spreadsheet to {export_path}")
if __name__ == "__main__":
main()
"""Generate a styled games scoreboard spreadsheet artifact.
This script demonstrates how to assemble a multi-sheet `SpreadsheetArtifact`
similar to ``sample_jsons/GamesSimpleStyling.json`` using the higher-level API.
Run it to emit the workbook JSON to stdout or pass ``--output`` to write it to disk.
"""
from __future__ import annotations
import argparse
from pathlib import Path
from pprint import pprint
from oaiproto.coworker.pptx.utils_pb2 import Color, Fill, TextStyle
from oaiproto.coworker.xlsx.spreadsheet_pb2 import CfRule, DifferentialFormat
from artifact_tool import FileOutputType, SpreadsheetArtifact
from artifact_tool.spreadsheet.conditional_formatting import CfType, len_greater_than_zero_formula
HEADER_FILL_HEX = "FFB7E1CD"
HIGHLIGHT_FILL_HEX = "FFFFF2CC"
"""
This creates a simple spreadsheet with two sheets, one for Game X and one for Game Y.
With a simple header style row and players filled in.
It demonstrates how to create styles and apply them to cells.
It demonstrates how to create conditional formatting, merge cells, etc.
Example:
`python examples/spreadsheets/create_spreadsheet_with_styling.py --output ~/tmp/styled_xlsx.xlsx --format xlsx --render`
"""
def solid_fill(color_hex: str) -> Fill:
"""Return a solid fill proto for the given RGB hex color."""
normalized = color_hex.lstrip("#").upper()
return Fill(type="FILL_TYPE_SOLID", color=Color(type="COLOR_TYPE_RGB", value=normalized))
def create_styles(artifact: SpreadsheetArtifact) -> dict[str, int]:
"""Register reusable styles on the workbook and return their indices."""
# Header style: bold font, pastel fill, centered alignment.
text_style = TextStyle(name="Aptos Narrow", family=2, scheme="minor", font_size=11, bold=True)
header_cell_style_index = artifact.create_cell_format(
text_style=text_style,
fill=solid_fill(HEADER_FILL_HEX),
horizontal_alignment="center",
vertical_alignment="center",
)
# Highlight style reused for winner callouts.
highlight_cell_style_index = artifact.create_cell_format(
fill=solid_fill(HIGHLIGHT_FILL_HEX),
text_style=text_style,
horizontal_alignment="center",
vertical_alignment="center",
)
return {
"header": header_cell_style_index,
"highlight": highlight_cell_style_index,
}
def populate_first_game_sheet(artifact: SpreadsheetArtifact, style_indices: dict[str, int]) -> None:
"""Create the "GameX" sheet with scores and a summary row."""
sheet = artifact.sheet("GameX")
sheet.set_sheet_styles(default_row_height=15.75)
sheet.set_row_height(2, 35.25)
sheet.set_column_widths("C", 13.1640625)
sheet.set_column_widths("D", 13.5)
sheet.set_column_widths("E", 11.1640625)
sheet.set_column_widths("F", 40)
headers_range = sheet.range("A2:G2")
headers_range.set_values(
[["", "Name", "Game 1 Score", "Game 2 Score", "Total Score", "Notes", ""]]
)
headers_range.set_style_index(style_indices["header"])
name_score_range = sheet.range("B3:D5")
name_score_range.set_values(
[
["Vicky", 12, 30],
["Yash", 20, 10],
["Bobby", 1000, 1030],
]
)
# Set the total score formula column
total_score_range = sheet.range("E3:E5")
total_score_range.set_formulas([["=SUM(C3:D3)"], ["=SUM(C4:D4)"], ["=SUM(C5:D5)"]])
notes_column = sheet.range("F3:F5")
notes_column.set_values(
[
["Dominated the minigames."],
["Emily main with strong defense."],
["Numbers look suspiciously high."],
]
)
# Actually, reset F5
sheet.cell("F5").value = "Rematch penciled in for Friday."
# Now, fill in a last row for the summary row - 7th row
sheet.cell("B7").value = "Winner"
sheet.cell("C7").formula = "=INDEX(B4:B6, MATCH(MAX(E4:E6), E4:E6, 0))"
sheet.cell("E7").value = "Congrats!"
sheet.range("B7:E7").set_style_index(style_indices["highlight"])
# Let's merge C7 and D7
sheet.range("C7:D7").merge()
sheet.create_conditional_formatting(
ranges=["A2:G2"],
rules=[
CfRule(
type=CfType.NOT_CONTAINS_BLANKS,
formula=[len_greater_than_zero_formula("A2")],
)
],
style=DifferentialFormat(fill=solid_fill(HEADER_FILL_HEX)),
)
def build_workbook() -> SpreadsheetArtifact:
"""Create the scoreboard workbook with both sheets populated."""
artifact = SpreadsheetArtifact("GamesSimpleStyling")
style_indices = create_styles(artifact)
populate_first_game_sheet(artifact, style_indices)
return artifact
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Generate the GamesSimpleStyling workbook JSON")
parser.add_argument(
"--output",
type=Path,
help=("Optional destination file. Leave unset to print the workbook to_dict() to stdout."),
)
parser.add_argument(
"--format",
choices=["json", "bin", "xlsx"],
default="json",
help="Output type to use when saving the workbook.",
)
parser.add_argument(
"--render",
action="store_true",
default=False,
help="Render the workbook to PNG images.",
)
return parser.parse_args()
def main() -> None:
args = parse_args()
artifact = build_workbook()
output_format = args.format
if args.output:
args.output.parent.mkdir(parents=True, exist_ok=True)
if output_format == "json":
file_type = FileOutputType.C_STAR_PROTO_JSON
elif output_format == "bin":
file_type = FileOutputType.C_STAR_PROTO_BINARY
elif output_format == "xlsx":
file_type = FileOutputType.XLSX
else:
raise ValueError(f"Invalid output type: {output_format}")
path = artifact.save(
file_type=file_type,
filename=args.output,
overwrite=True,
)
print("Saving workbook to", path)
else:
workbook_dict = artifact.to_dict()
print("Workbook created successfully: to_dict()")
pprint(workbook_dict)
if args.render:
render_paths = artifact.render()
print("Rendered workbook to", render_paths)
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from artifact_tool import SpreadsheetArtifact
def main() -> None:
file_path = Path(__file__).resolve().parent / ".." / "sample_xlsx" / "weather_sf.xlsx"
spreadsheet = SpreadsheetArtifact.read(file_path=file_path)
dashboard = spreadsheet.sheet("Dashboard")
print(f"Charts before deletion: {len(dashboard.charts)}")
for i, chart in enumerate(dashboard.charts):
print(f"Chart {i}: {chart.title}")
del dashboard.charts[0]
print(f"Charts after deletion: {len(dashboard.charts)}")
for i, chart in enumerate(dashboard.charts):
print(f"Chart {i}: {chart.title}")
if __name__ == "__main__":
main()
from pathlib import Path
from artifact_tool import SpreadsheetArtifact
def main() -> None:
spreadsheet = SpreadsheetArtifact("CiteDemo")
first_sheet = spreadsheet.sheet("Sheet1")
# Example data.
first_sheet.range("A1:C3").set_values(
[
["Note", "hello", "hello"],
["a", "b", "c"],
["d", "e", "f"],
]
)
# Add note on the range (anchors to top-left A1 by default).
first_sheet.range("A1:C3").cite(
tether_id="123456789",
start_line_number=12,
end_line_number=18,
)
first_sheet.cell("A4").set_value("This is a note on the cell A4.")
first_sheet.cell("A4").cite(tether_id="1234567890", start_line_number=23, end_line_number=46)
# Inspect proto->dict verification.
output_dir = Path(__file__).resolve().parent / "golden_rendered_images" / "cite_cells"
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
# as_dict = spreadsheet.to_dict()
# print(as_dict)
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from oaiproto.coworker.pptx.chart_pb2 import Chart
from artifact_tool import FileOutputType, SpreadsheetArtifact
def main() -> None:
# New spreadsheet artifact
spreadsheet = SpreadsheetArtifact("Scores")
game_sheet = spreadsheet.sheet("MyFavoriteGame")
# Seed some data
game_sheet["A1:C1"].values = [["Player", "Game 1", "Game 2"]]
game_sheet["A2:C5"].values = [
["Vicky", 120, 100],
["Yash", 134, 95],
["Dibyo", 95, 110],
["Bobby", 105, 105],
]
# Set up some ranges to use as labels (categories) and values for the charts
labels = game_sheet.range("A2:A5")
game1 = game_sheet.range("B2:B5")
game2 = game_sheet.range("C2:C5")
# Add an area chart to the cell range E2:I14
chart1 = game_sheet.charts.add(
game_sheet.range("E2:I14"),
Chart.ChartType.CHART_TYPE_AREA,
title="Game Scores",
)
chart1.add_series("Game 1", categories_range=labels, values_range=game1)
chart1.add_series("Game 2", categories_range=labels, values_range=game2)
output_dir = Path(__file__).resolve().parent / "golden_rendered_images" / "create_area_chart"
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
spreadsheet.save(
file_type=FileOutputType.C_STAR_PROTO_JSON,
filename=output_dir / "workbook__auto.json",
overwrite=True,
)
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from oaiproto.coworker.pptx.chart_pb2 import BarDirection, BarGrouping, Chart
from artifact_tool import FileOutputType, SpreadsheetArtifact
from artifact_tool.models.charts import BarChart
def main() -> None:
# New spreadsheet artifact
spreadsheet = SpreadsheetArtifact("Scores")
game_sheet = spreadsheet.sheet("MyFavoriteGame")
# Seed some data
game_sheet["A1:C1"].values = [["Player", "Game 1", "Game 2"]]
game_sheet["A2:C5"].values = [
["Vicky", 120, 100],
["Emily", 134, 95],
["Dibyo", 95, 110],
["Bobby", 105, 105],
]
# Set up some ranges to use as labels (categories) and values for the charts
labels = game_sheet.range("A2:A5")
game1 = game_sheet.range("B2:B5")
game2 = game_sheet.range("C2:C5")
# Add a vertical bar chart to the cell range E2:I14
chart1 = game_sheet.charts.add(
game_sheet.range("E2:I14"),
Chart.ChartType.CHART_TYPE_BAR,
title="Game Scores",
)
chart1.add_series("Game 1", categories_range=labels, values_range=game1)
chart1.add_series("Game 2", categories_range=labels, values_range=game2)
# Add a horizontal bar chart to the cell range E17:I29
chart2 = game_sheet.charts.add(
game_sheet.range("E17:I29"),
Chart.ChartType.CHART_TYPE_BAR,
title="Total Scores",
)
assert isinstance(chart2, BarChart)
chart2.bar_direction = BarDirection.BAR_DIRECTION_BAR
chart2.bar_grouping = BarGrouping.BAR_GROUPING_STACKED
chart2.add_series("Game 1", categories_range=labels, values_range=game1)
chart2.add_series("Game 2", categories_range=labels, values_range=game2)
output_dir = Path(__file__).resolve().parent / "golden_rendered_images" / "create_bar_chart"
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
spreadsheet.save(
file_type=FileOutputType.C_STAR_PROTO_JSON,
filename=output_dir / "workbook__auto.json",
overwrite=True,
)
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from oaiproto.coworker.pptx.chart_pb2 import Chart, LegendPosition
from artifact_tool import FileOutputType, SpreadsheetArtifact
def main() -> None:
# New spreadsheet artifact
spreadsheet = SpreadsheetArtifact("Scores")
first_game_sheet = spreadsheet.sheet("Game1")
# Seed some data
first_game_sheet["A1:C1"].values = [["Player", "Game 1", "Game 2"]]
first_game_sheet["A2:C5"].values = [
["Vicky", 120, 100],
["Emily", 134, 95],
["Dibyo", 95, 110],
["Bobby", 105, 105],
]
# Set up some ranges to use as labels (categories) and values for the charts
labels = first_game_sheet.range("A2:A5")
game1 = first_game_sheet.range("B2:B5")
# Add a doughnut chart to the cell range E2:I14
chart1 = first_game_sheet.charts.add(
first_game_sheet.range("E2:I14"),
Chart.ChartType.CHART_TYPE_DOUGHNUT,
title="Game Scores",
)
chart1.add_series("Game 1", categories_range=labels, values_range=game1)
# Show the legend and position it to the right
chart1.legend.visible = True
chart1.legend.position = LegendPosition.LEGEND_POSITION_RIGHT
output_dir = (
Path(__file__).resolve().parent / "golden_rendered_images" / "create_doughnut_chart"
)
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
spreadsheet.save(
file_type=FileOutputType.C_STAR_PROTO_JSON,
filename=output_dir / "workbook__auto.json",
overwrite=True,
)
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from oaiproto.coworker.pptx.chart_pb2 import Chart
from artifact_tool import FileOutputType, SpreadsheetArtifact
def main() -> None:
# New spreadsheet artifact
spreadsheet = SpreadsheetArtifact("Scores")
first_sheet = spreadsheet.sheet("GameX")
# Seed some data
first_sheet["A1:C1"].values = [["Player", "Game 1", "Game 2"]]
first_sheet["A2:C5"].values = [
["Vicky", 120, 100],
["Emily", 134, 95],
["Dibyo", 95, 110],
["Bobby", 105, 105],
]
# Set up some ranges to use as labels (categories) and values for the charts
labels = first_sheet.range("A2:A5")
game1 = first_sheet.range("B2:B5")
game2 = first_sheet.range("C2:C5")
# Add a line chart to the cell range E2:I14
chart1 = first_sheet.charts.add(
first_sheet.range("E2:I14"),
Chart.ChartType.CHART_TYPE_LINE,
title="Game Scores",
)
chart1.add_series("Game 1", categories_range=labels, values_range=game1)
chart1.add_series("Game 2", categories_range=labels, values_range=game2)
output_dir = Path(__file__).resolve().parent / "golden_rendered_images" / "create_line_chart"
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
spreadsheet.save(
file_type=FileOutputType.C_STAR_PROTO_JSON,
filename=output_dir / "workbook__auto.json",
overwrite=True,
)
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from oaiproto.coworker.pptx.chart_pb2 import Chart, LegendPosition
from artifact_tool import FileOutputType, SpreadsheetArtifact
def main() -> None:
# New spreadsheet artifact
spreadsheet = SpreadsheetArtifact("Scores")
first_sheet = spreadsheet.sheet("GameX")
# Seed some data
first_sheet["A1:C1"].values = [["Player", "Game 1", "Game 2"]]
first_sheet["A2:C5"].values = [
["Vicky", 120, 100],
["Emily", 134, 95],
["Dibyo", 95, 110],
["Bobby", 105, 105],
]
# Set up some ranges to use as labels (categories) and values for the charts
labels = first_sheet.range("A2:A5")
game1 = first_sheet.range("B2:B5")
# Add a pie chart to the cell range E2:I14
chart1 = first_sheet.charts.add(
first_sheet.range("E2:I14"),
Chart.ChartType.CHART_TYPE_PIE,
title="Game Scores",
)
chart1.add_series("Game 1", categories_range=labels, values_range=game1)
# Show the legend and position it to the right
chart1.legend.visible = True
chart1.legend.position = LegendPosition.LEGEND_POSITION_RIGHT
output_dir = Path(__file__).resolve().parent / "golden_rendered_images" / "create_pie_chart"
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
spreadsheet.save(
file_type=FileOutputType.C_STAR_PROTO_JSON,
filename=output_dir / "workbook__auto.json",
overwrite=True,
)
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from artifact_tool import FileOutputType, SpreadsheetArtifact
def main() -> None:
# New spreadsheet artifact
spreadsheet = SpreadsheetArtifact("Scores")
first_sheet = spreadsheet.sheet("FirstGame")
# Seed some data
first_sheet.range("A1:C1").set_values([["Player", "Game", "Score"]])
first_sheet.range("A2:C5").set_values(
[
["Vicky", "1", 100],
["Emily", "1", 95],
["Dibyo", "2", 110],
["Bobby", "2", 105],
]
)
# Create a table over the data range
table = first_sheet.add_table(
"A1:C5", has_headers=True, name="ScoresTable", style_name="TableStyleMedium2"
)
table.set_style(show_row_stripes=True)
# Expand only the last two columns and the first two rows to compare
first_sheet.set_column_widths("B:C", 24)
for row_idx in range(1, 3):
first_sheet.set_row_height(row_idx, 28)
# Inspect proto->dict verification.
output_dir = Path(__file__).resolve().parent / "golden_rendered_images" / "create_tables"
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
spreadsheet.save(
file_type=FileOutputType.C_STAR_PROTO_JSON,
filename=output_dir / "workbook__auto.json",
overwrite=True,
)
if __name__ == "__main__":
main()
from __future__ import annotations
from pathlib import Path
from oaiproto.coworker.pptx.utils_pb2 import Color
from oaiproto.coworker.xlsx.spreadsheet_pb2 import Border, BorderLine
from artifact_tool import FileOutputType, SpreadsheetArtifact
def main() -> None:
spreadsheet = SpreadsheetArtifact("Borders")
first_sheet = spreadsheet.sheet("BorderExamples")
first_sheet.cell("B2").set_value("Bottom border")
first_sheet.cell("B2").format.borders.bottom = BorderLine(style="thin")
first_sheet.cell("B4").set_value("Top border")
first_sheet.cell("B4").format.borders.top = BorderLine(style="thin")
first_sheet.cell("B6").set_value("Left border")
first_sheet.cell("B6").format.borders.left = BorderLine(style="thin")
first_sheet.cell("B8").set_value("Right border")
first_sheet.cell("B8").format.borders.right = BorderLine(style="thin")
first_sheet.cell("B10").set_value("All borders")
first_sheet.cell("B10").format.borders.set(
top=BorderLine(style="thin"),
right=BorderLine(style="thin"),
bottom=BorderLine(style="thin"),
left=BorderLine(style="thin"),
)
first_sheet.cell("B12").set_value("Thick borders")
first_sheet.cell("B12").format.borders.set(
top=BorderLine(style="thick"),
right=BorderLine(style="thick"),
bottom=BorderLine(style="thick"),
left=BorderLine(style="thick"),
)
first_sheet.cell("B14").set_value("Bottom double border")
first_sheet.cell("B14").format.borders.bottom = BorderLine(style="double")
first_sheet.cell("B16").set_value("Thick bottom border")
first_sheet.cell("B16").format.borders.bottom = BorderLine(style="thick")
first_sheet.cell("B18").set_value("Top and thick bottom border")
first_sheet.cell("B18").format.borders.set(
top=BorderLine(style="thin"), bottom=BorderLine(style="thick")
)
first_sheet.cell("B20").set_value("Top and double bottom border")
first_sheet.cell("B20").format.borders.set(
top=BorderLine(style="thin"), bottom=BorderLine(style="double")
)
highlight_color = Color(type="COLOR_TYPE_RGB", value="FFFF6F00")
accent_color = Color(type="COLOR_TYPE_RGB", value="FF1F75FE")
first_sheet.cell("B22").set_value("Colorful borders")
first_sheet.cell("B22").format.borders.set(
top=BorderLine(style="thin", color=highlight_color),
right=BorderLine(style="thin", color=highlight_color),
bottom=BorderLine(style="thin", color=highlight_color),
left=BorderLine(style="thin", color=highlight_color),
)
first_sheet.cell("B24").set_value("Dashed borders")
first_sheet.cell("B24").format.borders.set(
top=BorderLine(style="mediumDashed", color=highlight_color),
right=BorderLine(style="mediumDashed", color=highlight_color),
bottom=BorderLine(style="mediumDashed", color=highlight_color),
left=BorderLine(style="mediumDashed", color=highlight_color),
)
first_sheet.cell("B26").set_value("All sorts of borders")
first_sheet.cell("B26").format.borders.set(
top=BorderLine(style="mediumDashed", color=accent_color),
right=BorderLine(style="thin", color=accent_color),
left=BorderLine(style="thin", color=accent_color),
bottom=BorderLine(style="thick", color=accent_color),
)
first_sheet.cell("B28").set_value("Diagonal up")
first_sheet.cell("B28").format.borders.set(
border=Border(diagonal=BorderLine(style="thin", color=highlight_color), diagonal_up=True),
)
first_sheet.cell("B30").set_value("Diagonal down")
first_sheet.cell("B30").format.borders.set(
border=Border(diagonal=BorderLine(style="thin", color=accent_color), diagonal_down=True),
)
output_dir = Path(__file__).resolve().parent / "golden_rendered_images" / "set_cell_borders"
output_path = spreadsheet.render(output=output_dir)
print(f"Spreadsheet rendered to {output_path}")
# output_path = spreadsheet.export()
# print(f"Spreadsheet exported to {output_path}")
spreadsheet.save(
file_type=FileOutputType.C_STAR_PROTO_JSON,
filename=output_dir / "workbook__auto.json",
overwrite=True,
)
if __name__ == "__main__":
main()