> For the complete documentation index, see [llms.txt](https://docs.yemreak.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yemreak.com/arsiv/programming/typescriptle-google-spreadsheet-ile-google-sheet-duzenlemek.md).

# Typescriptle google-spreadsheet ile google sheet duzenlemek

sheet, typescript, programming, google-spreadsheet

![](https://i.imgur.com/lZSfQcw.png)

* <https://github.com/theoephraim/node-google-spreadsheet> kutuphanesi ile guncelleme islemlerini yapabiliriz
* Dokumantasyonu icin [buraya](https://theoephraim.github.io/node-google-spreadsheet/#/?id=working-with-rows) bakabilirsiniz, [auth islemleri](https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication)

<details>

<summary>`worksheet` kullanmadan once `load` etmeniz gerekir, aksi halde hata verir</summary>

```typescript
await worksheet.loadHeaderRow()
const headers = worksheet.headerValues.entries()

await worksheet.loadCells({
	startRowIndex: rowIndex,
	endRowIndex: rowIndex + 1,
	startColumnIndex: colIndex,
	endColumnIndex: colIndex + 2,
})
const assetCell = worksheet.getCell(rowIndex, colIndex + assetOffset)
```

</details>

<details>

<summary>Ilk `row` ve `col` degerini header row olarak aldigi icin, $row_{sheet} = row_{code} + 1$</summary>

\- Yani \`sheet\` de yer alan \`2\` satir icin code icerisinden \`1\` indeksi ile erisirsiniz - Ayni durum \`col\` indeks hesabi icin de gecerlidir

</details>

<details>

<summary>`value = x` atamalarindan sonra `save` yapmayi unutmayin</summary>

```typescript
const assetCell = worksheet.getCell(rowIndex, colIndex + assetOffset)
assetCell.value = 4
await assetCell.save() // Bunu yapmazsaniz sheet'e yazmaz
```

</details>

## Periyodik Olarak Worksheet’e veri Gondermek

```typescript
import { JWT } from "google-auth-library"
import {
	GoogleSpreadsheet,
	type GoogleSpreadsheetWorksheet,
} from "google-spreadsheet"

export type GoogleSheetCredential = {
	client_email: string
	private_key: string
	spreadsheetId: string
	worksheetName: string
}
export type GoogleSheetConfig = { sheetIntervalHour?: number }
export type GoogleSheetManagerInit = GoogleSheetCredential & GoogleSheetConfig
export class GoogleSheetManager {
	private readonly spreadSheet: GoogleSpreadsheet

	private readonly worksheetName: string
	private readonly sheetIntervalHour: number

	intervalId?: NodeJS.Timeout

	constructor(init: GoogleSheetManagerInit) {
		const { spreadsheetId, client_email, private_key } = init
		const auth = new JWT({
			email: client_email,
			key: private_key,
			scopes: [
				"https://www.googleapis.com/auth/spreadsheets",
				"https://www.googleapis.com/auth/drive.file",
			],
		})
		this.spreadSheet = new GoogleSpreadsheet(spreadsheetId, auth)

		this.worksheetName = init.worksheetName
		this.sheetIntervalHour = init.sheetIntervalHour ?? 1
	}

	static async start(
		init: GoogleSheetManagerInit & {
			onPushInterval: (worksheet: GoogleSpreadsheetWorksheet) => Promise<void>
		}
	): Promise<GoogleSheetManager> {
		const sheetManager = new GoogleSheetManager(init)
		await sheetManager.spreadSheet.loadInfo()

		const worksheet =
			sheetManager.spreadSheet.sheetsByTitle[sheetManager.worksheetName]
		await worksheet.loadHeaderRow()

		await init.onPushInterval(worksheet)
		sheetManager.intervalId = setInterval(async () => {
			await init.onPushInterval(worksheet)
		}, sheetManager.sheetIntervalHour * 60 * 60 * 1000)
		return sheetManager
	}
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.yemreak.com/arsiv/programming/typescriptle-google-spreadsheet-ile-google-sheet-duzenlemek.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
