1. 제품
  2.   Aspose.Cells
  3.   Aspose.Cells FOSS for Go

Go용 Aspose.Cells FOSS

Go에서 Excel 스프레드시트를 생성, 수정 및 내보내기 — 무료이며 오픈소스, 외부 의존성 전혀 없음.

Excel 스프레드시트를 위한 오픈 소스 Go 라이브러리

Aspose.Cells FOSS for Go은 Go 애플리케이션에서 Excel 스프레드시트 파일을 다루기 위한 무료 오픈 소스 라이브러리입니다. go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26를 사용해 설치하고 워크북 생성, 셀 읽기·쓰기, 스타일 적용, 데이터 유효성 검사 추가, CSV로 내보내기를 시작하세요. Microsoft Excel이나 Office 의존성이 필요 없습니다.

이 라이브러리는 Workbook, Worksheet, Cells, Cell을 중심으로 구성된 작고 관용적인 Go API를 제공합니다. Cells() 컬렉션을 통해 Get/Set/Remove로 셀에 접근하고, Font, Fill, Alignment, Border로 만든 재사용 가능한 Style 객체로 서식을 그룹화하며, 헤더 행과 명명된 테이블 스타일이 포함된 구조화된 Table 범위를 구축합니다. 전용 StreamingReader는 콜백을 통해 .xlsx 워크북을 행 단위로 읽어 대용량 파일도 전체 시트를 메모리에 로드하지 않고 처리할 수 있습니다.

go.mod는 외부 종속성을 선언하지 않습니다 — 이 라이브러리는 Go 표준 라이브러리만으로 완전히 구축되었습니다. MIT 라이선스를 사용하며 GitHub에 호스팅되고, 단일 go get 명령으로 설치됩니다; cgo도 없고, 네이티브 Office 라이브러리도 없으며, 구성할 시스템 패키지도 없습니다. 엔터프라이즈 제품군은 Aspose.Cells — Enterprise Product Family를 참고하세요.

Excel 파일 읽기 및 쓰기

  • Cell access: Cells().Get(ref) / Cells().Set(ref, value) 로 값을 읽고 쓸 수 있습니다.
  • Formulas: Cell.SetFormula/GetFormula 는 셀에 수식 문자열을 저장합니다 — 저장 시 라이브러리가 아니라 Excel 또는 LibreOffice가 열 때 평가합니다.
  • CSV interop: Workbook.ExportToCSV/ImportFromCSV 와 Worksheet.ToCSV/FromCSV 는 XLSX와 CSV 간 변환을 수행합니다.
  • Streaming reads: StreamingReader.ProcessRows 는 콜백을 통해 워크시트를 행 단위로 스트리밍하여, 전체 시트를 메모리에 로드하지 않고 대용량 파일을 처리합니다.
  • Password protection: Workbook.SetPassword/VerifyPassword 로 워크북 비밀번호를 보호하고 확인합니다.

Aspose.Cells FOSS를 사용할 수 있는 경우

  • 데이터 파이프라인: 데이터베이스 쿼리 결과를 XLSX 또는 CSV로 직접 내보냅니다.
  • 보고서 생성: Go 백엔드 서비스에서 스타일이 적용된 Excel 보고서를 만듭니다.
  • 대용량 파일 처리: StreamingReader를 사용하여 메모리에 완전히 로드하지 않고 수천 행에 달하는 워크북을 스트리밍합니다.
  • ETL 워크플로: 입력 시트를 읽고, 데이터를 변환한 뒤, 출력 워크북을 씁니다.
  • CI/CD 자동화: Go 기반 빌드 파이프라인 및 Docker 컨테이너 내에서 스프레드시트 아티팩트를 생성합니다.

스타일링, 데이터 유효성 검사 및 테이블

  • Style objects: Font(name, size, bold, italic, color), Fill(type, color), Alignment(horizontal, vertical, wrap text), 그리고 Border(top/bottom/left/right, color)를 재사용 가능한 Style로 그룹화하고 Cell.SetStyle로 적용합니다.
  • Data validation: Worksheet.AddDataValidation은 목록 및 정수 범위 검증 규칙을 연결하고, 각각 사용자 지정 오류 제목, 메시지 및 오류 스타일을 가집니다.
  • Tables: Worksheet.AddTable/GetTable은 선택적 헤더 행과 명명된 테이블 스타일을 가진 구조화된 Table 범위를 생성합니다.
  • Pictures: Worksheet.AddPicture는 SetAnchor(row, col) 위치 지정으로 이미지 Picture를 삽입합니다.

개발자 경험

Aspose.Cells FOSS for Go은(는) 단일 go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26 명령으로 설치됩니다. go.mod에 require 항목이 없으며 — 검토하거나 벤더링할 외부 종속성이 없습니다.

API 인터페이스는 의도적으로 간결합니다: Workbook, Worksheet, Cells, Cell, Style 및 소수의 지원 타입이 스프레드시트 생성, 스타일링, 검증, 그리고 CSV/스트리밍 I/O를 포괄합니다. 코드베이스는 MIT 라이선스를 갖고 있으며 GitHub에 호스팅됩니다.

워크북 생성 및 셀 쓰기

go get으로 설치하고, Workbook을 생성한 뒤 첫 번째 Worksheet에 접근하고, 저장하기 전에 Cells() 컬렉션을 통해 셀에 직접 값을 씁니다.

go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26
func main() {
	wb := cells_foss.NewWorkbook()
	ws := wb.Worksheets[0]
	ws.Cells().Set("A1", "Hello")
	ws.Cells().Set("B1", "World")
	ws.Cells().Set("A2", "Answer")
	ws.Cells().Set("B2", 42)
	outPath := "outputfiles/basic.xlsx"
	if err := wb.Save(outPath); err != nil {
		fmt.Printf("Error saving workbook: %v\n", err)
		return
	}
	fmt.Printf("Workbook saved to %s\n", outPath)
}

데이터 유효성 검사 규칙 추가

목록 유형 검증(허용 값의 드롭다운)과 정수 범위 검증을 두 개의 서로 다른 열에 각각 고유한 오류 제목과 메시지를 지정하여 추가합니다.

func main() {
	wb := cells_foss.NewWorkbook()
	ws := wb.Worksheets[0]
	ws.Cells().Set("A1", "Fruit")
	ws.Cells().Set("A2", "Apple")
	ws.Cells().Set("A3", "Banana")
	dv := &cells_foss.DataValidation{
		Type:             cells_foss.DataValidationTypeList,
		Formula1:         `"Apple,Banana,Cherry,Dragonfruit"`,
		AllowBlank:       true,
		ShowErrorMessage: true,
		ErrorTitle:       "Invalid Fruit",
		ErrorMessage:     "Please pick a fruit from the list.",
		ErrorStyle:       cells_foss.ErrorStyleStop,
	}
	if err := ws.AddDataValidation("A2:A10", dv); err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}
	dv2 := &cells_foss.DataValidation{
		Type:             cells_foss.DataValidationTypeWhole,
		Formula1:         "1",
		Formula2:         "100",
		ShowErrorMessage: true,
		ErrorTitle:       "Invalid Value",
		ErrorMessage:     "Enter a whole number between 1 and 100.",
		ErrorStyle:       cells_foss.ErrorStyleWarning,
	}
	ws.Cells().Set("B1", "Score (1-100)")
	ws.AddDataValidation("B2:B10", dv2)
	outPath := "outputfiles/data_validation.xlsx"
	if err := wb.Save(outPath); err != nil {
		fmt.Printf("Error saving workbook: %v\n", err)
		return
	}
	fmt.Printf("Workbook saved to %s\n", outPath)
}

대용량 워크북을 행별로 스트리밍

StreamingReader는 콜백을 통해 워크시트를 한 행씩 읽으므로, 수천 행에 달하는 워크북을 메모리에 완전히 로드할 필요가 없습니다.

func main() {
	genPath := "outputfiles/streaming_data.xlsx"
	sr := cells_foss.NewStreamingReader(genPath)
	rowCount := 0
	var totalScore float64
	err := sr.ProcessRows("Sheet1", func(rowIdx int, cells map[string]string) error {
		rowCount++
		if rowIdx == 1 {
			fmt.Printf("  Header: %v\n", cells)
			return nil
		}
		if score, ok := cells["C"+fmt.Sprint(rowIdx)]; ok {
			var s float64
			fmt.Sscanf(score, "%f", &s)
			totalScore += s
		}
		return nil
	})
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error streaming: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("Streamed %d rows (header + %d data rows)\n", rowCount, rowCount-1)
}

자주 묻는 질문

Aspose.Cells FOSS for Go의 라이선스 모델은 무엇입니까?

Aspose.Cells FOSS for Go은 MIT 라이선스에 따라 배포되며, 이는 상업 및 오픈소스 사용을 허용합니다.

상업용 제품에 사용할 수 있나요?

예. MIT 라이선스는 원본 저작권 고지를 유지하는 한, 자체 소스 코드를 공개할 의무 없이 상업적 사용을 허용합니다.

Aspose.Cells FOSS for Go를 어떻게 설치합니까?

Go 모듈 종속성으로 go get github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Go/v26와 함께 추가하십시오. Go 1.24 이상이 필요합니다.

외부 의존성이 있나요?

아니요. go.mod는 require 항목을 선언하지 않으며 — 라이브러리는 Go 표준 라이브러리만을 사용하여 완전히 구축됩니다.

전체를 메모리에 로드하지 않고 큰 워크북을 처리할 수 있나요?

예. StreamingReader.ProcessRows는 콜백을 통해 워크시트를 한 행씩 읽어 전체 메모리 로드를 피합니다.

  

지원 및 학습 자료

 한국어