패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.0

excel_to_json

다중 시트 지원 및 포괄적인 오류 처리 기능을 갖춘 Excel(.xlsx) 파일을 JSON 형식으로 변환하는 Flutter 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
566
좋아요
24
Pub 점수
160

패키지 설치

flutter pub add excel_to_json

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

엑셀(.xlsx) 파일을 JSON 형식으로 변환하는 플러터 패키지로, 여러 시트를 지원하고 강력한 오류 처리 기능을 제공합니다. 주요 플랫폼 전반에서 스프레드시트 데이터를 플러터 애플리케이션에 원활하게 통합할 수 있습니다. 복잡한 스프레드시트에서도 정확한 파싱과 신뢰할 수 있는 결과를 보장하여 구조화된 데이터를 앱으로 가져오는 데 이상적입니다. 외부 종속성 없이 엑셀에서 JSON으로의 효율적인 데이터 변환이 필요한 개발자를 위해 설계되었습니다.

사용 사례

  • Flutter 앱으로 Excel 파일에서 데이터 가져오기
  • 다중 시트 Excel 파일을 JSON으로 변환하기
  • 웹 및 모바일 앱에서 구조화된 스프레드시트 데이터 파싱
  • Excel 소스에서 데이터 인제스트 자동화
  • 오류 회복 능력을 갖춘 대규모 또는 복잡한 엑셀 파일 처리

주요 기능

  • 하나의 Excel 파일에서 여러 워크시트를 지원합니다
  • 손상된 파일에 대한 포괄적인 오류 처리
  • 크로스 플랫폼 호환성 (Android, iOS, Web, macOS, Windows, Linux)
  • Excel을 JSON으로 변환하는 간단한 API
  • 변환 중 데이터 유형을 유지합니다

적합한 대상

  • 엑셀 데이터 가져오기 기능이 필요한 앱을 개발하는 개발자
  • 구조화된 스프레드시트 데이터를 사용하는 팀
  • 엑셀에서 자동 데이터 처리가 필요한 애플리케이션
  • 오프라인 데이터 가져오기를 필요로 하는 모바일 및 웹 앱
  • Excel에서 JSON으로의 데이터 마이그레이션을 포함하는 프로젝트

고려 사항

  • 성공적인 변환을 위해서는 유효한 .xlsx 파일이 필요합니다
  • 큰 파일은 저사양 장치의 성능에 영향을 줄 수 있습니다
  • Excel (.xlsx) 형식만 가능, .xls 불가
  • 파일 선택을 위한 내장된 UI가 없습니다 (파일 피커와 통합해야 함)
  • 정확도는 하위 파싱 라이브러리에 따라 달라집니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Excel to JSON

pub package License: MIT pub points popularity

A Flutter package that converts Excel (.xlsx) files to JSON format, making it easy to work with spreadsheet data in your Flutter applications.

🚀 Quick Example

import 'package:excel_to_json/excel_to_json.dart';

// Simple conversion
final converter = ExcelToJson();
final jsonString = await converter.convert(); // Opens file picker

// With custom configuration  
final converter = ExcelToJson(
  config: ExcelToJsonConfig(
    includeEmptyRows: true,
    verbose: true,
  ),
);
final result = await converter.convert();

Features

✅ Simple Integration - Easy to use API with just a few lines of code
✅ Multiple Worksheets - Supports Excel files with multiple sheets
✅ Type Safety - Handles various cell types (text, numbers, dates, formulas, booleans)
✅ Configurable - Customizable conversion options
✅ Error Handling - Comprehensive error reporting and logging
✅ Cross Platform - Works on Android, iOS, Web, and Desktop

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  excel_to_json: ^1.5.0

Then run:

flutter pub get

Quick Start

Basic Usage
import 'package:excel_to_json/excel_to_json.dart';

void convertExcelToJson() async {
  final converter = ExcelToJson();
  
  try {
    final jsonString = await converter.convert();
    if (jsonString != null) {
      print('Conversion successful!');
      print(jsonString);
    } else {
      print('No file selected or conversion cancelled.');
    }
  } on ExcelToJsonException catch (e) {
    print('Conversion failed: ${e.message}');
  }
}
Advanced Usage with Configuration
import 'package:excel_to_json/excel_to_json.dart';

void convertWithConfig() async {
  const config = ExcelToJsonConfig(
    includeEmptyRows: true,        // Include rows with all empty cells
    useDateTimeStrings: false,     // Keep date objects as native types
    verbose: true,                 // Enable detailed logging
  );
  
  final converter = ExcelToJson(config: config);
  
  try {
    final jsonString = await converter.convert();
    if (jsonString != null) {
      // Process your JSON data
      final data = jsonDecode(jsonString);
      
      // Access worksheets by name
      final sheet1Data = data['Sheet1'] as List<dynamic>;
      for (final row in sheet1Data) {
        print('Row data: $row');
      }
    }
  } on ExcelToJsonException catch (e) {
    print('Error: ${e.message}');
    if (e.cause != null) {
      print('Caused by: ${e.cause}');
    }
  }
}

Configuration Options

The ExcelToJsonConfig class provides several options to customize the conversion:

Option Type Default Description
includeEmptyRows bool false Include rows where all cells are empty
useDateTimeStrings bool true Convert date/time values to strings
dateFormat String? null Custom date format pattern (future feature)
verbose bool false Enable detailed logging during conversion

Output Format

The package converts Excel files to JSON with the following structure:

{
  "Sheet1": [
    {
      "Name": "John Doe",
      "Age": 30,
      "Email": "john@example.com"
    },
    {
      "Name": "Jane Smith",
      "Age": 25,
      "Email": "jane@example.com"
    }
  ],
  "Sheet2": [
    {
      "Product": "Widget",
      "Price": 19.99,
      "InStock": true
    }
  ]
}

Each worksheet becomes a top-level property, and each row (except the header) becomes an object in the array.

Supported Cell Types

The package handles all standard Excel cell types:

  • Text - String values
  • Numbers - Integer and floating-point numbers
  • Booleans - TRUE/FALSE values
  • Dates - Date values (converted to strings by default)
  • Times - Time values (converted to strings by default)
  • DateTime - Combined date and time values
  • Formulas - Formula expressions (shows the formula, not the result)
  • Empty cells - Represented as null in JSON

Error Handling

The package provides detailed error information through the ExcelToJsonException class:

try {
  final result = await converter.convert();
} on ExcelToJsonException catch (e) {
  print('Conversion failed: ${e.message}');
  
  // Check if there's an underlying cause
  if (e.cause != null) {
    print('Underlying error: ${e.cause}');
  }
}

Platform Support

This package supports all platforms where Flutter runs:

  • ✅ Android
  • ✅ iOS
  • ✅ Web
  • ✅ Windows
  • ✅ macOS
  • ✅ Linux

Limitations

  • Only supports .xlsx files (Excel 2007+ format)
  • Does not support .xls files (Excel 97-2003 format)
  • Formula results are not calculated (shows formula text instead)
  • Charts, images, and other embedded objects are ignored

Example App

Check out the /example folder for a complete Flutter app demonstrating how to use this package.

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup
  1. Fork the repository
  2. Clone your fork: git clone https://github.com/yourusername/excel_to_json.git
  3. Install dependencies: flutter pub get
  4. Run tests: flutter test
  5. Make your changes and add tests
  6. Submit a pull request

Changelog

See CHANGELOG.md for a detailed list of changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you find this package helpful, please give it a ⭐ on GitHub and pub.dev!

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.