Skip to content

Commit

Permalink
feat: grey readonly cells
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbrugger committed Oct 20, 2023
1 parent c90494c commit acf23cf
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-goats-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@flatfile/plugin-export-workbook': minor
---

This is a release candidate introducing Excel formatting
2 changes: 1 addition & 1 deletion plugins/export-workbook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flatfile/plugin-export-workbook",
"version": "0.0.9",
"version": "0.1.0-rc.0",
"description": "A plugin for exporting data in Flatfile to Workbooks.",
"registryMetadata": {
"category": "export"
Expand Down
27 changes: 24 additions & 3 deletions plugins/export-workbook/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import api, { Flatfile } from '@flatfile/api'
import { FlatfileEvent } from '@flatfile/listener'
import { processRecords } from '@flatfile/util-common'
import * as XLSX from '@sheet/coredemo'
import * as fs from 'fs'
import * as R from 'remeda'
import * as XLSX from './xlsx.full.min.js'

/**
* Plugin config options.
Expand Down Expand Up @@ -107,6 +107,7 @@ export const run = async (
`A1:${alphaColumnDesignations[columnCount - 1]}1`,
{
bold: true,
...readonlyColorScheme,
}
)

Expand Down Expand Up @@ -141,6 +142,21 @@ export const run = async (
)
}

const readonlyFieldAlphaColumnDesignations =
alphaColumnDesignations.filter(
(designation) =>
!editableFieldAlphaColumnDesignations.includes(designation)
)
for (const columnDesignation of readonlyFieldAlphaColumnDesignations) {
XLSX.utils.sheet_set_range_style(
worksheet,
`${columnDesignation}2:${columnDesignation}${rowCount}`,
{
...readonlyColorScheme,
}
)
}

XLSX.utils.book_append_sheet(
workbook,
worksheet,
Expand Down Expand Up @@ -263,8 +279,8 @@ export const run = async (
}

type ColorScheme = {
color: { rgb: string }
fgColor: { rgb: string }
color?: { rgb: string }
fgColor?: { rgb: string }
}

const errorRed: ColorScheme = {
Expand All @@ -282,6 +298,11 @@ const infoBlue: ColorScheme = {
fgColor: { rgb: 'daeef3' },
}

const readonlyColorScheme: ColorScheme = {
color: { rgb: '414857' },
fgColor: { rgb: 'f6f8fc' },
}

function getCellColorScheme(
messages: Flatfile.ValidationMessage[]
): ColorScheme | null {
Expand Down
28 changes: 28 additions & 0 deletions plugins/export-workbook/src/xlsx.full.min.js

Large diffs are not rendered by default.

0 comments on commit acf23cf

Please sign in to comment.