1. Produk
  2.   Hamparan
  3.   Ruby
  4.   Creek
 
  

Pustaka Ruby Percuma untuk Menjalankan Pemprosesan Fail XLSX Excel Besar Secara Jauh

Pustaka Ruby Sumber Terbuka yang Kuat untuk Menjalankan Pemprosesan Fail XLSX dan XLSM Excel Berskala Besar Secara Jauh. Ia Menyokong Pemprosesan Fail dan Imej Jauh, Memetakan Tajuk, dan sebagainya.

Apakah Pustaka Creek?

Dalam dunia pemprosesan data, mengendalikan fail Excel yang besar boleh menjadi tugas yang menakutkan, sering menyebabkan kebocoran prestasi dan penggunaan memori yang tinggi. Di sinilah Creek, sebuah perpustakaan Ruby sumber terbuka yang berkuasa direka untuk memproses fail Excel yang besar dengan kecekapan luar biasa. Ia merupakan alat yang efisien untuk memproses fail Excel yang besar, menonjolkan ciri-ciri penting seperti pemprosesan aliran, sokongan pelbagai jenis fail, dan pilihan penggunaan yang fleksibel dalam skrip bersendirian dan aplikasi Rails. Ia memberikan sokongan lengkap untuk operasi asas, pemprosesan gambar, dan pengendalian fail jauh, menjadikannya sumber yang berharga bagi pemaju yang ingin mengoptimumkan aliran kerja pemprosesan data mereka.

Creek adalah perpustakaan sumber terbuka yang kukuh, efisien, dan berfokus untuk memproses fail Excel .xlsx / .xlsm dalam Ruby. Ia merupakan gem Ruby yang menyediakan cara pantas dan mudah untuk membaca serta memproses fail Excel besar (XLSX dan XLSM). Ia menggunakan pemprosesan aliran, yang bermakna ia membaca fail secara berperingkat berbanding memuat keseluruhan fail ke dalam memori. Pendekatan ini menjadikan Creek sangat cekap dari segi memori dan ideal untuk aplikasi yang berurusan dengan set data berskala besar. Sama ada anda sedang bekerja pada skrip Ruby bersendirian atau aplikasi Rails, Creek menawarkan pengalaman integrasi yang lancar. Jika projek anda melibatkan lembaran kerja besar, gambar, metadata, atau muatan fail Rails, Creek memberikan banyak fungsi yang diperlukan dengan overhead yang minimum.

Previous Next

Mula Menggunakan Creek

Cara yang disyorkan untuk memasang perpustakaan Creek adalah dengan menggunakan RubyGems. Sila gunakan arahan berikut untuk pemasangan yang lancar.

Pasang Creek melalui RubyGems

$ gem install Creek  

Pemprosesan Fail Excel Besar melalui Ruby

The cornerstone of open source Creek library is its stream parsing capability. This feature allows you to process large Excel files without worrying about memory overloads. By reading the file in chunks, Creek ensures that your application remains responsive and stable, even when handling files with hundreds of thousands of rows. The most common use case is to open a file and read data from its worksheets. Here is a simple example that demonstrates, how software developers can parse an Excel file via Ruby library.

Bagaimana Cara Memproses Fail Excel XLSX Besar melalui Perpustakaan Ruby?

require 'creek'

# Open the Excel file
creek = Creek::Book.new 'path/to/your/sample.xlsx'

# Get the first sheet
sheet = creek.sheets[0]

# Loop through rows with cell coordinates
sheet.rows.each do |row|
  puts row
  # => {"A1"=>"Content 1", "B1"=>nil, "C1"=>"Content 2"}
end

# Loop through rows without cell coordinates
sheet.simple_rows.each do |row|
  puts row
  # => {"A"=>"Content 1", "B"=>nil, "C"=>"Content 2"}
End

Pemprosesan & Pengekstrakan Imej melalui Pustaka Ruby

While not enabled by default to conserve memory, the Creek library can parse images from your Excel files. By using the with_images method, you can preload and extract images from cells. The images are returned as an array of Pathname objects, making them easy to work with. Here is a simple example that demonstrates, how software developers can parse and extract I mages from an Excel spreadsheet via Ruby Library.

Bagaimana Cara Memproses dan Mengekstrak Gambar dari Lembar Kerja Excel melalui Perpustakaan Ruby?

require 'creek'

book = Creek::Book.new 'presentation.xlsx'
sheet = book.sheets.first

sheet.with_images.rows.each do |row|
  row.each do |coord, value|
    if value.is_a?(Array)
      # this cell has images
      puts "Images at #{coord}: #{value.inspect}"
    else
      puts "#{coord}: #{value}"
    end
  end
end

# Images at a specific cell
images = sheet.images_at('B2')
if images
  images.each do |path|
    puts "Found image file: #{path}"
  end
else
  puts "No image at B2"
end

Pemprosesan Fail Jauh melalui Pustaka Ruby

Need to parse an Excel file from a URL? The Creek library has you covered. By setting the remote: true option, you can parse files directly from a remote server, eliminating the need to download them first. You can parse files from URLs or paths even if they don’t have .xlsx or .xlsm extensions. The extension check can be skipped. The argument check_file_extension can be provided to bypass extension enforcement. Here is a simple example for parsing Excel files remotely via Ruby library.

Bagaimana Cara Memproses Fail Excel XLSX Secara Jarak Jauh melalui Perpustakaan Ruby?

remote_url = 'http://example.com/sample.xlsx'
creek = Creek::Book.new remote_url, remote: true
# ... process the file

Pemprosesan Fail XLSX dan XLSM melalui Ruby

The open source ruby library Creek supports both the standard XLSX and the macro-enabled XLSM file formats, providing flexibility for various use cases. This ensures that you can handle a wide range of Excel files without needing multiple libraries.

 Melayu