1. Produtos
  2.   Planilha
  3.   Swift
  4.   SwiftXLSX
 
  

Biblioteca Swift gratuita para ler, escrever e converter arquivos Excel XLSX

Crie, edite, manipule e converta planilhas Excel XLSX, aplique estilos e extraia dados diretamente em dispositivos móveis usando a biblioteca Swift de código aberto.

O que é SwiftXLSX?

No mundo do desenvolvimento de software moderno, a capacidade de trabalhar com vários formatos de arquivo é essencial. Um dos formatos de arquivo mais onipresentes em negócios e análise de dados é a planilha Excel. Seja analisando dados, gerando relatórios ou simplesmente precisando interagir com arquivos Excel em sua aplicação Swift, a biblioteca SwiftXLSX é uma ferramenta valiosa no seu kit. É uma biblioteca Swift de código aberto projetada para simplificar o processo de leitura e escrita de arquivos Excel no formato XLSX. Se você é um desenvolvedor Swift encarregado de analisar dados, gerar relatórios ou gerenciar arquivos Excel dentro de sua aplicação, o SwiftXLSX pode ser muito útil para facilitar seu trabalho.

SwiftXLSX foi projetado para ser fácil de usar e integra-se perfeitamente aos seus projetos Swift. Esta biblioteca simplifica o processo de trabalho com arquivos Excel, tornando tarefas como extração de dados, manipulação e geração de relatórios simples. Existem várias funcionalidades importantes na biblioteca, como leitura e escrita de documentos Excel XLSX, extração de dados de células específicas, linhas ou colunas, ordenação de dados, filtragem e cálculo de valores nas planilhas, aplicação de formatação e estilos às células, entre outras. A biblioteca foi projetada para funcionar em diferentes plataformas, incluindo iOS, macOS e Linux.

The SwiftXLSX library is a powerful and versatile tool for Swift developers who need to work with Excel files. Being written in Swift, the library seamlessly integrates with your existing Swift codebase. This means you can leverage the full power of the Swift programming language while working with Excel files. Whether you're building a data analysis tool, a reporting feature, or simply need to interact with Excel files in your application, it simplifies the process and provides a robust set of features to handle your Excel-related tasks. With its ease of use, cross-platform support, and strong integration with Swift, it's a valuable addition to any Swift developer's toolbox.

Previous Next

Iniciando com SwiftXLSX

The recommend way to install SwiftXLSX is using CocoaPods. Please use the following command for a smooth installation.

Instalar SwiftXLSX via CocoaPods

 pod "SwiftXLSX"

pod install

You can download it directly from GitHub.

Leitura e escrita de arquivos Excel via API Swift

The open source SwiftXLSX library allows software developers to create a new file from the scratch with just a couple of lines of Swift code. Software developers can load and read data from existing Excel files with ease. There are several other important features part of the library, such as importing Excel files, extracting data from existing files, making modifications, and saving the results back into Excel format with ease. The following example shows how software developers can read data from an Excel file using SwiftXLSX library.

Como ler dados de um arquivo Excel usando a API Swift?

import SwiftXLSX
import SwiftXLSX

do {
    let filePath = "path/to/your/excel-file.xlsx"
    let file = try XLSXFile(filepath: filePath)
    for path in try file.parseWorksheetPaths() {
        let ws = try file.parseWorksheet(at: path)
        for row in ws.data?.dropFirst() ?? [] {
            for cell in row {
                print(cell)
            }
        }
    }
} catch {
    print("Error reading Excel file: \(error)")
}

Aplicar estilos e formatação ao arquivo Excel via Swift

Applying styling and formatting to Excel files using the SwiftXLSX library allows you to customize the appearance of your Excel sheets, making them more visually appealing and informative. Software developers can format cells, change font settings, apply borders, and set background colors to highlight specific data. Here's how you can apply styling and formatting to an Excel file inside Swift Applications.

Como aplicar estilos e formatação à planilha Excel usando Swift?

import SwiftXLSX

// Create a new Excel file
let file = XLSXFile()

do {
    let ws = try file.parseWorksheet(at: 0) // Replace 0 with the index of the worksheet you want to format
} catch {
    print("Error parsing worksheet: \(error)")
}

// Font Settings

let font = Font(family: .roman, bold: true, size: 12)
ws.cell(at: CellReference("A1")).style.font = font

// Background Color:

ws.cell(at: CellReference("B2")).style.fill = Fill(patternType: .solid, fgColor: Color(.yellow))

// Borders:
let border = Border(style: .thin, color: Color(.black))
ws.cell(at: CellReference("C3")).style.borders = Borders(left: border, right: border, top: border, bottom: border)

// Number Format:

ws.cell(at: CellReference("D4")).style.numberFormat = .number

//Save the File:

let savePath = "path/to/save/your/excel-file.xlsx"
do {
    try file.save(to: savePath)
} catch {
    print("Error saving Excel file: \(error)")
}

Extração e manipulação de dados via API Swift

The open source SwiftXLSX library allows software developers to manipulate data inside Excel Spreadsheet using Swift API. The library allows to perform various data manipulation operations, such as sorting, filtering, and calculating values within Excel sheets. This makes it an ideal tool for tasks like data analysis and reporting. Moreover, software developers can easily extract data from specific cells, rows, or columns within an Excel sheet using Swift API. This is incredibly useful when dealing with large datasets and only needing specific information.

 Português