Graph Excel
v0.7.0Read and edit Excel workbooks on SharePoint/OneDrive via Microsoft Graph, with verified writes.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
login_status
Check the Microsoft Graph sign-in. If not signed in, starts a device code login and returns the URL + code: give them to the user (never sign in for them), then call login_status again once they say they're done.
resolve
Workbook info: driveId/itemId, last modified (when/by whom), and every sheet with its used range.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
read_range
Read one contiguous range (e.g. H60:J60). Each cell comes with sha256:<hash> to pass back as `expected` when writing. fills=true adds each cell's fill color (≤400 cells). hashOnly=true omits the text (just hash + length).
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
range * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
fills | boolean | |
hashOnly | boolean |
write_values
Write blocks of cell values. Each block is one contiguous range with a 2D `values` array (a scalar for one cell). `expected` (same shape; exact text, sha256:<hash>, or null to skip a cell) is the base check: a block whose current content differs is skipped as a conflict, never half-written. After writing, every block is read back and compared (status written-verified / written-mismatch). Values are interpreted like typed input: text that looks like a number/date may be converted — mismatches report it.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
writes * | array | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
append_update
Write the 「-----update-----」 part of cells in one row (e.g. H/I/J) and keep the original part byte-identical. No separator yet: appends blank line + separator + text. Separator present: mode=replace (default) swaps the update part, mode=append adds after it. Pass `expected` per column (sha256 from read_range) as the base check. After writing it verifies the original part is intact, then fills `fillRange` (default the updated columns of that row) with `fill` (default #FFFF00; null = no fill).
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
row * | integer | |
sheet * | string | Worksheet name exactly as listed by resolve |
update * | object | Column letter -> update text, e.g. {"H": "1. ...", "J": "..."} |
expected | object | Column letter -> exact current text or sha256:<hash> |
fill | string | null | |
fillRange | string | |
mode | string | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
set_fill
Set or clear the fill color of one or more contiguous ranges (non-contiguous rows = several ranges; sent in one batch). color "#FFFF00" etc., or null to clear. Verified by reading the fill back.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
ranges * | array | |
sheet * | string | Worksheet name exactly as listed by resolve |
color | string | null | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
find
Search cell text across every sheet (or one `sheet`): case-insensitive substring by default, regex=true for a JavaScript regular expression. Returns sheet, address, a preview and the sha256 hash per hit (≤ limit, default 50, max 500).
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
text * | string | |
limit | integer | |
matchCase | boolean | |
regex | boolean | |
sheet | string | Worksheet name exactly as listed by resolve |
add_sheet
Add an empty worksheet (Excel name rules, no duplicate names), optionally at `position` (0 = first). Verified by listing the sheets afterwards.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
name * | string | |
position | integer | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
rename_sheet
Rename a worksheet (Excel name rules, no duplicate names). Formulas that refer to it follow the new name. Verified by listing the sheets afterwards.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
newName * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
insert_rows
Insert `count` empty rows above `row`; everything from `row` down shifts down. The dry run shows the row that will move. Verified afterwards: that row is found at row+count and the new rows are empty.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
row * | integer | |
sheet * | string | Worksheet name exactly as listed by resolve |
count | integer | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
append_rows
Append rows below the last used row of a sheet, starting at `column` (default A). `values` is a 2D array, one array per row. Base check: the target cells must still be empty; read back and verified like write_values.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
values * | array | |
column | string | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
set_format
Format one or more contiguous ranges: bold, italic, fontColor (#RRGGBB), fontSize, wrapText, horizontalAlignment (General/Left/Center/Right/Justify), verticalAlignment (Top/Center/Bottom/Justify/Distributed), numberFormat (e.g. "yyyy-mm-dd", "0.00", "@" for text). Font changes are read back and verified. Fill colors: use set_fill.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
ranges * | array | |
sheet * | string | Worksheet name exactly as listed by resolve |
bold | boolean | |
fontColor | string | |
fontSize | number | |
horizontalAlignment | string | |
italic | boolean | |
numberFormat | string | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
verticalAlignment | string | |
wrapText | boolean |
set_layout
Column widths, row heights, autofit and hiding. columns: [{columns: "B" or "C:E", width (characters, as in Excel's Column Width dialog) | widthPt | autofit | hidden}]. rows: [{rows: "5" or "1:18", height (points) | autofit | hidden}]. Applied in order: widths/hidden, heights, then autofit (row autofit depends on column widths and wrapText — set wrap with set_format first). Excel does not autofit rows for merged cells. Widths, heights and hidden are read back and verified.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
columns | array | |
rows | array | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
merge_cells
Merge or unmerge cells. Either `ranges` (each merged into one cell; across=true merges each row separately) or `groupBy`: one column (B3:B18) or row range split into groups — a value starts a group, equal values and blanks below extend it — and every group longer than one cell is merged (e.g. a category column). Refuses when a merge would drop data (Excel keeps only the top-left value; equal copies are fine). Graph can't read merges back: the result reports the request status and that the kept value is intact.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
across | boolean | |
groupBy | string | |
ranges | array | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
unmerge | boolean |
set_borders
Draw or clear borders on one or more ranges. sides default to the outline plus inside lines (EdgeTop, EdgeBottom, EdgeLeft, EdgeRight, InsideVertical, InsideHorizontal; DiagonalDown/DiagonalUp also allowed). style Continuous (default), Dash, DashDot, DashDotDot, Dot, Double, SlantDashDot or None to clear; weight Hairline, Thin (default), Medium, Thick; color #RRGGBB (default #000000). Read back and verified.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
ranges * | array | |
sheet * | string | Worksheet name exactly as listed by resolve |
color | string | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
sides | array | |
style | string | |
weight | string |
insert_columns
Insert `count` empty columns left of `column`; everything from `column` rightwards shifts right. Verified: the shifted column is intact and the new columns are empty.
| Parameter | Type | Description |
|---|---|---|
column * | string | |
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
count | integer | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
delete_rows
Delete whole rows ("7" or "7:9"); rows below shift up. The dry run shows what holds data there and a contentHash; deleting needs send=true AND expected = that contentHash, so a change made in between is caught. Verified: the next row moved up intact.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
rows * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
expected | string | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
delete_columns
Delete whole columns ("C" or "C:E"); columns to the right shift left. The dry run shows what holds data there and a contentHash; deleting needs send=true AND expected = that contentHash. Verified: the next column moved left intact.
| Parameter | Type | Description |
|---|---|---|
columns * | string | |
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
expected | string | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
clear_range
Clear one or more ranges without shifting cells. applyTo Contents (default: values and formulas), Formats, or All. When clearing contents, the dry run returns a contentHash per block; pass them as `expected` (same order) with send=true. Verified: the cells are empty.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
ranges * | array | |
sheet * | string | Worksheet name exactly as listed by resolve |
applyTo | string | |
expected | array | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
set_sheet_visibility
Hide (visible=false) or show (visible=true) a worksheet. At least one sheet must stay visible.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
visible * | boolean | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
delete_sheet
Delete a worksheet. The dry run shows how much data it holds; deleting needs send=true AND confirmName equal to the sheet name. Formulas elsewhere that refer to it turn into #REF!. The last sheet can't be deleted. Only when the user asked to delete that exact sheet.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
confirmName | string | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
bridge_status
Status of the Excel add-in bridge, which the tools below need: whether it's on (GRAPH_EXCEL_BRIDGE=1), paired, and which workbooks have the graph-excel bridge task pane open. If not paired yet (or pair=true) it returns a 6-digit pairing code: give it to the user to type in the task pane. Never pair on their behalf.
| Parameter | Type | Description |
|---|---|---|
pair | boolean |
get_validation
Read the data validation (dropdown list, number/date/length limits, custom formula) of a range. Needs the add-in task pane open on that workbook.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
range * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
set_validation
Set or clear data validation on a range — through the Excel add-in (Graph has no API for it). Exactly one of: list {values: ["OK","NG"]} or {source: "=Lists!$A$2:$A$20"} (a dropdown), wholeNumber / decimal / date / time / textLength {operator, formula1, formula2?}, custom {formula: "=..."}; or clear=true. Optional prompt {title, message}, errorAlert {style Stop|Warning|Information, title, message}, ignoreBlanks. The dry run shows the current rule and, for a list, cells whose value isn't in it. A range that already has a rule needs replace=true. Read back after writing.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
range * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
clear | boolean | |
custom | object | |
date | object | |
decimal | object | |
errorAlert | object | |
ignoreBlanks | boolean | |
list | object | |
prompt | object | |
replace | boolean | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
textLength | object | |
time | object | |
wholeNumber | object |
list_conditional_formats
List the conditional formats that apply to a range (id, type, priority, applies-to range). Needs the add-in task pane open.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
range * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
set_conditional_format
Add, delete (deleteIds from list_conditional_formats) or clear all conditional formats on a range — through the Excel add-in. Each `add` item: {kind, rule, format {fill, fontColor, bold}}. kinds: cellValue {operator, formula1, formula2?} (text in quotes, e.g. formula1 "\"NG\""), containsText {text, operator?}, custom {formula "=$H5=\"NG\""}, colorScale {criteria {minimum, midpoint?, maximum: {type: "LowestValue"|"HighestValue"|"Number"|"Percent"|"Percentile", formula?, color}}}, dataBar {color?}, topBottom {rank, type?}, duplicates {unique?}. Verified by listing again.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
range * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
add | array | |
clearAll | boolean | |
deleteIds | array | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
set_view
Freeze panes and the sheet's filter buttons — through the Excel add-in. freeze {rows, columns} (e.g. {rows: 1} keeps the header visible) or null to unfreeze; autoFilter a range with headers (e.g. A4:L500) or null to remove. Changes everyone's view of the sheet.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
sheet * | string | Worksheet name exactly as listed by resolve |
autoFilter | string | null | |
freeze | object | null | |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
copy_sheet
Duplicate a sheet right after it, with everything (values, formulas, formats, validation, conditional formats, charts), and name the copy. Through the Excel add-in.
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
newName * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |
send | boolean | false (default) = dry run: shows what would change. true = write — only after the user approved (or a standing rule allows it) |
get_merged_areas
List the merged areas inside a range (e.g. to check merge_cells). Through the Excel add-in (needs ExcelApi 1.13).
| Parameter | Type | Description |
|---|---|---|
file * | string | Workbook: SharePoint URL, an alias from ~/.graph-excel/workbooks.json, or "driveId:itemId" |
range * | string | |
sheet * | string | Worksheet name exactly as listed by resolve |