-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
57 lines (51 loc) · 1.76 KB
/
App.tsx
File metadata and controls
57 lines (51 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { useRef } from 'react'
import { Reogrid } from '@reogrid/lite/react'
import type { ReogridInstance } from '@reogrid/lite/react'
export default function App() {
const gridRef = useRef<ReogridInstance>(null)
function onReady({ worksheet }: ReogridInstance) {
// Column widths
worksheet.column(0).width = 100 // A
worksheet.column(1).width = 160 // B
worksheet.column(2).width = 80 // C
worksheet.column(3).width = 60 // D
worksheet.column(4).width = 80 // E
// Header row
worksheet.range('A1:E1').setStyle({
bold: true,
backgroundColor: '#1e3a5f',
color: '#ffffff',
})
worksheet.cell('A1').value = '商品コード'
worksheet.cell('B1').value = '商品名'
worksheet.cell('C1').value = '単価'
worksheet.cell('D1').value = '数量'
worksheet.cell('E1').value = '金額'
// Sample data
const rows = [
['P-001', 'ウィジェットA', 1000, 5, 5000],
['P-002', 'ウィジェットB', 2500, 3, 7500],
['P-003', 'ウィジェットC', 500, 10, 5000],
]
rows.forEach((row, i) => {
const r = i + 2
worksheet.cell(`A${r}`).value = String(row[0])
worksheet.cell(`B${r}`).value = String(row[1])
worksheet.cell(`C${r}`).value = String(row[2])
worksheet.cell(`D${r}`).value = String(row[3])
worksheet.cell(`E${r}`).value = String(row[4])
})
}
return (
<div style={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
<header style={{ padding: '0.5rem 1rem', background: '#1e3a5f', color: '#fff' }}>
<h1 style={{ margin: 0, fontSize: '1rem' }}>ReoGrid Lite — React Example</h1>
</header>
<Reogrid
ref={gridRef}
onReady={onReady}
style={{ flex: 1 }}
/>
</div>
)
}