Excel

Excel

Only for questions on programming against Excel objects or files, or complex formula development. You may combine the Excel tag with VBA, VSTO, C#, VB.NET, PowerShell, OLE automation, and other programming related tags and questions if applicable.

How to Lock Cells in Excel using Python

This video will show you how to lock cells in Excel using Python. The process is simple, and the code is short, so you can make sure your spreadsheet is protected from accidental editing with just a few lines of code. We will look at how you can lock cells by their fill colour, font style, formula or cell value. This is really helpful if you have a lot of data and you want to protect it from being tampered with.
A quick note: This method will only work on Windows, as we are going to use the pywin32 library.

𝗧𝗜𝗠𝗘𝗦𝗧𝗔𝗠𝗣𝗦: 
00:00 – Intro 
00:37 – Coding out the solution
06:05 – Outro

𝗥𝗘𝗦𝗢𝗨𝗥𝗖𝗘𝗦:
Source Code: https://github.com/Sven-Bo/lock-excel-cells-python 

Subscribe: https://www.youtube.com/c/CodingIsFun/featured 

#python #excel 

How to Lock Cells in Excel using Python
Rupert  Beatty

Rupert Beatty

1658684220

Fast-excel: Fast Excel Import/export for Laravel

Fast Excel import/export for Laravel, thanks to Spout. See benchmarks below.

Quick start

Install via composer:

composer require rap2hpoutre/fast-excel

Export a Model to .xlsx file:

use Rap2hpoutre\FastExcel\FastExcel;
use App\User;

// Load users
$users = User::all();

// Export all users
(new FastExcel($users))->export('file.xlsx');

Export

Export a Model or a Collection:

$list = collect([
    [ 'id' => 1, 'name' => 'Jane' ],
    [ 'id' => 2, 'name' => 'John' ],
]);

(new FastExcel($list))->export('file.xlsx');

Export xlsx, ods and csv:

$invoices = App\Invoice::orderBy('created_at', 'DESC')->get();
(new FastExcel($invoices))->export('invoices.csv');

Export only some attributes specifying columns names:

(new FastExcel(User::all()))->export('users.csv', function ($user) {
    return [
        'Email' => $user->email,
        'First Name' => $user->firstname,
        'Last Name' => strtoupper($user->lastname),
    ];
});

Download (from a controller method):

return (new FastExcel(User::all()))->download('file.xlsx');

Import

import returns a Collection:

$collection = (new FastExcel)->import('file.xlsx');

Import a csv with specific delimiter, enclosure characters and "gbk" encoding:

$collection = (new FastExcel)->configureCsv(';', '#', 'gbk')->import('file.csv');

Import and insert to database:

$users = (new FastExcel)->import('file.xlsx', function ($line) {
    return User::create([
        'name' => $line['Name'],
        'email' => $line['Email']
    ]);
});

Facades

You may use FastExcel with the optional Facade. Add the following line to config/app.php under the aliases key.

'FastExcel' => Rap2hpoutre\FastExcel\Facades\FastExcel::class,

Using the Facade, you will not have access to the constructor. You may set your export data using the data method.

$list = collect([
    [ 'id' => 1, 'name' => 'Jane' ],
    [ 'id' => 2, 'name' => 'John' ],
]);

FastExcel::data($list)->export('file.xlsx');

Global helper

FastExcel provides a convenient global helper to quickly instantiate the FastExcel class anywhere in a Laravel application.

$collection = fastexcel()->import('file.xlsx');
fastexcel($collection)->export('file.xlsx');

Advanced usage

Export multiple sheets

Export multiple sheets by creating a SheetCollection:

$sheets = new SheetCollection([
    User::all(),
    Project::all()
]);
(new FastExcel($sheets))->export('file.xlsx');

Use index to specify sheet name:

$sheets = new SheetCollection([
    'Users' => User::all(),
    'Second sheet' => Project::all()
]);

Import multiple sheets

Import multiple sheets by using importSheets:

$sheets = (new FastExcel)->importSheets('file.xlsx');

You can also import a specific sheet by its number:

$users = (new FastExcel)->sheet(3)->import('file.xlsx');

Import multiple sheets with sheets names:

$sheets = (new FastExcel)->withSheetsNames()->importSheets('file.xlsx');

Export large collections with chunk

Export rows one by one to avoid memory_limit issues using yield:

function usersGenerator() {
    foreach (User::cursor() as $user) {
        yield $user;
    }
}

// Export consumes only a few MB, even with 10M+ rows.
(new FastExcel(usersGenerator()))->export('test.xlsx');

Add header and rows style

Add header and rows style with headerStyle and rowsStyle methods.

$header_style = (new StyleBuilder())->setFontBold()->build();

$rows_style = (new StyleBuilder())
    ->setFontSize(15)
    ->setShouldWrapText()
    ->setBackgroundColor("EDEDED")
    ->build();

return (new FastExcel($list))
    ->headerStyle($header_style)
    ->rowsStyle($rows_style)
    ->download('file.xlsx');

Why?

FastExcel is intended at being Laravel-flavoured Spout: a simple, but elegant wrapper around Spout with the goal of simplifying imports and exports. It could be considered as a faster (and memory friendly) alternative to Laravel Excel, with less features. Use it only for simple tasks.

Benchmarks

Tested on a MacBook Pro 2015 2,7 GHz Intel Core i5 16 Go 1867 MHz DDR3. Testing a XLSX export for 10000 lines, 20 columns with random data, 10 iterations, 2018-04-05. Don't trust benchmarks.

 Average memory peak usageExecution time
Laravel Excel123.56 M11.56 s
FastExcel2.09 M2.76 s

Still, remember that Laravel Excel has many more features.

Author: rap2hpoutre
Source Code: https://github.com/rap2hpoutre/fast-excel 
License: MIT license

#laravel #excel #php 

Fast-excel: Fast Excel Import/export for Laravel
Rupert  Beatty

Rupert Beatty

1658676720

Laravel Excel: Supercharged Excel Exports and Imports in Laravel

Supercharged Excel exports and imports

A simple, but elegant Laravel wrapper around PhpSpreadsheet exports and imports.     

✨ Features

Easily export collections to Excel. Supercharge your Laravel collections and export them directly to an Excel or CSV document. Exporting has never been so easy.

Supercharged exports. Export queries with automatic chunking for better performance. You provide us the query, we handle the performance. Exporting even larger datasets? No worries, Laravel Excel has your back. You can queue your exports so all of this happens in the background.

Supercharged imports. Import workbooks and worksheets to Eloquent models with chunk reading and batch inserts! Have large files? You can queue every chunk of a file! Your entire import will happen in the background.

Export Blade views. Want to have a custom layout in your spreadsheet? Use a HTML table in a Blade view and export that to Excel.

banner 
 

🎓 Learning Laravel Excel

You can find the full documentation of Laravel Excel on the website.

We welcome suggestions for improving our docs. The documentation repository can be found at https://github.com/SpartnerNL/laravel-excel-docs.

Some articles and tutorials can be found on our blog: https://medium.com/maatwebsite/laravel-excel/home

:mailbox_with_mail: License & Postcardware

1_5nblgs68uarg0wxxejozdq

Laravel Excel is created with love and care by Spartner (formerly known as Maatwebsite) to give back to the Laravel community. It is completely free (MIT license) to use, however the package is licensed as Postcardware. This means that if it makes it to your production environment, we would very much appreciate receiving a postcard from your hometown.

Spartner Markt 2 6231 LS Meerssen The Netherlands.

More about the license can be found at: https://docs.laravel-excel.com/3.1/getting-started/license.html

Created by Spartner (formerly Maatwebsite)

We are a strategic development partner, creating web-based custom built software from Laravel. In need of a digital solution for your challenge? Give us a call.

https://spartner.software info@spartner.nl +31 (0) 10 - 7449312

🔧 Supported Versions

Versions will be supported for a limited amount of time.

VersionLaravel VersionPhp VersionSupport
2.1<=5.6<=7.0Unsupported since 15-5-2018
3.0^5.5^7.0Unsupported since 31-12-2018
3.1^5.8|^6.0|^7.0|^8.0^7.2|^8.0New features

Author: SpartnerNL
Source Code: https://github.com/SpartnerNL/Laravel-Excel 
License: MIT license

#laravel #excel #php #csv 

Laravel Excel: Supercharged Excel Exports and Imports in Laravel
Excel  Tutorial

Excel Tutorial

1658386617

How to Copy Data using Excel VBA

The Ultimate Guide to Copying Data using Excel VBA

In this video I'm going to cover everything you need to know about copying data using VBA. We're going to look at:
* What to avoid
* How to ensure your code runs fast
* How to get the correct worksheet every time
* An in-depth look at the 4 methods 
* The pros and cons of each method

Table of Contents:

00:00 - Introduction
00:26 - Don't do this 
01:06 - Speeding up your code
02:16 - Get the correct worksheet every time
02:31 - How to get the correct worksheet
05:45 - How to get the correct data range
07:11 - Method 1: For Loop & Range
12:38 - Method 2: For Loop - Arrays
16:26 - Method 3: Advanced Filter
26:40 - Method 4: ADO


Useful VBA Shortcut Keys
========================

Debugging:
Compile the code: Alt + D + L OR Alt + D + Enter
Run the code from the current sub: F5
Step into the code line by line: F8
Add a breakpoint to pause the code: F9(or click left margin)

Windows:
View the Immediate Window: Ctrl + G
View the Watch Window: Alt + V + H
View the Properties Window: F4
Switch between Excel and the VBA Editor: Alt + F11
View the Project Explorer Window: Ctrl + R

Writing Code:
Search keyword under cursor: Ctrl + F3
Search the word last searched for: F3
Auto complete word: Ctrl + Space
Get the definition of the item under the cursor: Shift + F2
Go to the last cursor position: Ctrl + Shift + F2
Get the current region on a worksheet: Ctrl + Shift + 8(or Ctrl + *)
To move lines of code to the right(Indent): Tab
To move lines of code to the left(Outdent): Shift + Tab
Delete a Line: Ctrl + Y(note: this clears the clipboard)

 

DOWNLOAD THE SOURCE CODE FOR THIS VIDEO:  https://bit.ly/3cflkjT 

Subscribe: https://www.youtube.com/c/Excelmacromastery/featured 

#excelvba #excel  

How to Copy Data using Excel VBA
Royce  Reinger

Royce Reinger

1657663140

A Wrapper Library That Specializes in The Operation Of Excel Win32ole

WrapExcel

Description

WrapExcel is a to wrap the win32ole, and easy to use Excel operations with ruby.

Requirements

ruby 1.9.2 or higher (platform is windows)

Install

gem install wrap_excel

Usage

access book

Read with block.

WrapExcel::Book.open('./sample.xls') do |book|
  # do something
end

Read without block.

book = WrapExcel::Book.open('./sample.xls')
book.close

Options are the following.

read_only

boolean(default true)

displayalerts

boolean(default false)

visible

boolean(default false)

access sheet

Sheet object can access with Book#[] method.

sheet = book[0]

Access with sheet name.

book['Sheet1']

access row or column

Sheet object is included enumerable. Use Sheet#each_column or Sheet#each_row or Sheet#each method.

sheet.each do |cell|
  # do something with cell
  # read every row every column
end

sheet.each_row do |row|
  # do something with row_range
end

sheet.each_column do |column_range|
  # do something with column_range
end

access cell

Read from sheet object.

sheet[0, 0]  => first cell.

Read from range object

row_range[0]  => first cell in row_range
column_range[1] => second cell in column_range

write excel

Can save an existing file.

WrapExcel::Book.open('./sample.xls', :read_only => false) do |book|
  # do something
  book.save
end

or

book = WrapExcel::Book.open('./sample.xls', :read_only => false)
book.save
book.close

Can save an another file name.

WrapExcel::Book.open('./sample.xls', :read_only => false) do |book|
  # do something
  book.save './another_file.xls'
end

Save to another_file.xls

Can not save new file.

Want to do more things

All WrapExcel object include win32ole instance. If you want to do something that not provide a function, you can use win32ole methods.

Support

Report issues and feature requests to github Issues. github.com/tomiacannondale/wrap_excel/issues

Collaborate

Please pull request on github.

Author: Tomiacannondale
Source Code: https://github.com/tomiacannondale/wrap_excel 
License: MIT license

#ruby #excel #wrapper 

A Wrapper Library That Specializes in The Operation Of Excel Win32ole
Royce  Reinger

Royce Reinger

1657655640

Oxcelix: A Fast and Simple .xlsx File Parser

Oxcelix

Oxcelix - A fast and simple .xlsx file parser

Description

Oxcelix is an xlsx (Excel 2007/2010) parser. The result of the parsing is a Workbook which is an array of Sheet objects, which in turn store the data in Matrix objects. Matrices consist of Cell objects to maintain comments and formatting/style data

Oxcelix uses the great Ox gem (http://rubygems.org/gems/ox) for fast SAX-parsing.

Synopsis

To process an xlsx file:

`require 'oxcelix'`
`w = Oxcelix::Workbook.new('whatever.xlsx')`

To omit certain sheets:

`w = Oxcelix::Workbook.new('whatever.xlsx', :exclude => ['sheet1', 'sheet2'])`

Include only some of the sheets:

`w = Oxcelix::Workbook.new('whatever.xlsx', :include => ['sheet1', 'sheet2', 'sheet3'])`

To have the values of the merged cells copied over the mergegroup:

`w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)`

Convert a Sheet object into a collection of ruby values or formatted ruby strings:

`require 'oxcelix'`
`w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)`
`w.sheets[0].to_ru # returns a Matrix of DateTime, Integer, etc objects`
`w.sheets[0].to_fmt # returns a Matrix of formatted Strings based on the above.`

OR:

`require 'oxcelix'`
`w = Oxcelix::RuValueWorkbook.new('whatever.xlsx', :copymerge => true)`
`w = Oxcelix::FormattedWorkbook.new('whatever.xlsx', :copymerge => true)`

You can parse an Excel file partially to save memory:

`require 'oxcelix'`
`w = Oxcelix::Workbook.new('whatever.xlsx', :cellrange => ('A3'..'R42')) # will only parse the cells included in the given range on every included sheet`
`w = Oxcelix::Workbook.new('whatever.xlsx', :paginate => [5,2]) # will only parse the second five-row group of every included sheet.`

Installation

gem install oxcelix

Advantages over other Excel parsers

Excel file processing involves XML document parsing. Usually, this is achieved by DOM-parsing the data with a suitable XML library.

The main drawbacks of this approach are memory usage and speed. The resulting object tree will be roughly as big as the original file, and during the parsing, they will both be stored in the memory, which can cause quite some complications when processing huge files. Also, interpreting every bit of an excel spreadsheet will slow down unnecessarily the process, if we only need the data stored in that file.

The solution for the memory-consumption problem is SAX stream parsing. This ensures that only the relevant XML elements get processed, without having to load the whole XML file in memory.

Oxcelix uses the SAX parser offered by Peter Ohler's Ox gem. I found Ox SAX parser quite fast, so to further speed up the parsing.

For a comparison of XML parsers, please consult the Ox homepage[http://www.ohler.com/dev/xml_with_ruby/xml_with_ruby.html].

TODO

  • Support for inline strings to be added
  • include/exclude mechanism should extend to cell areas inside Sheet objects
  • Further improvement to the formatting algorithms. Theoretically, to_fmt should be able to split conditional-formatting strings and to display e.g. thousands separated number strings

Author: gbiczo
Source Code: https://github.com/gbiczo/oxcelix 
License: MIT license

#ruby #excel #xlsx 

Oxcelix: A Fast and Simple .xlsx File Parser
Royce  Reinger

Royce Reinger

1657640700

Sheets: Work with Spreadsheets Easily in A Native Ruby format

Sheets

Sheets is a Facade on top of many spreadsheet formats, presenting them as simple, unified, native ruby arrays. It is intended to allow applications to easily import data from a wide variety of spreadsheet formats.

With Sheets, all cell values are strings representing the final, evaluated value of the cell.

This does mean that, in some cases, you will be casting data back into its native format.

However, this eliminates the need to deal with multiple spreadsheet formats and normalize data types in your application logic.

Your application only needs to care about the layout of the spreadsheet, and the format you want the data in.

Usage

Install via Rubygems:

gem install sheets

To retrieve a list of parseable spreadsheet formats at runtime:

Sheets::Base.parseable_formats # => ["csv", "xls", "xlsx", "ods"]

To open a spreadsheet, pass initialize Sheets::Base.new either a file path:

Sheets::Base.new( '/path/to/a/spreadsheet.(format)' )

or a file handle:

Sheets::Base.new( File.open('/path/to/a/spreadsheet.(format)') )

By default, Sheets will use the basename of the file to detect the spreadsheet type. You can override this by passing in the :format option:

This is necessary if you pass Sheets an IO object, like StringIO, that doesn't have metadata like a filename/path.

Sheets::Base.new( an_io_object_with_spreadsheet_data, :format => :xls )

Once you have imported a sheet, you can either grab the array:

sheet = Sheets::Base.new( # ... )
sheet.to_array

or utilize any of the Enumerable functions on the sheet:

sheet = Sheets::Base.new( # ... )
sheet.collect {|row| puts row }

Additionally, you may output the sheet in any of the renderable formats:

Sheets::Base.renderable_formats # => ['csv', 'xls']
sheet = Sheets::Base.new( file )
sheet.to_csv
sheet.to_xls

Sheets::Base will skip the parsing phase if initialized with an array, allowing you to render arrays to a native spreadsheet format:

my_awesome_data = [ ["Date", "Spent", "Earned"], ["2011-04-11", "$0.00", "$5,000.00"] ]
sheet = Sheets::Base.new( my_awesome_data )
sheet.to_csv
sheet.to_xls

Adding Parsers

Parsers subclass Sheets::Parsers::Base, live in the Sheets::Parsers namespace and should respond to two methods:

  • formats: returns an array of string format names (file extensions) that this parser class supports
  • to_array: returns a simple array representation of the spreadsheet.

Parsers have access to @data and @format in order to do their parsing. See lib/sheets/parsers/* for examples.

Adding Renderers

Renderers subclass Sheets::Renderers::Base, live in the Sheets::Renderers namespace and should respond to:

  • formats: returns an array of string format names that this parser class supports
  • to_#{format}: For each format that a renderer supports, it should respond to "to_#{format}", returning the file data of that format.

Renderers are given access to the results of Sheets::Base#to_array as @data. See lib/sheets/renderers/* for examples.

Test Suite Results

Sheets uses Travis-CI for Continuous Integration.

Build Status

Code Climate

Credits

Sheets takes advantage of the work done in these gems:

Author: Bspaulding
Source Code: https://github.com/bspaulding/Sheets 
License: MIT license

#ruby #spreadsheets #excel 

Sheets: Work with Spreadsheets Easily in A Native Ruby format
Royce  Reinger

Royce Reinger

1657625760

RubyXL: Ruby Lib for Reading/writing/modifying .xlsx and .xlsm Files

rubyXL

This gem supports operating on xlsx files (Open XML format). While it is capable of properly parsing the entire OOXML structure, its current main emphasis is on reading files produced by MS Excel, making minor modifications to them and saving them to be opened again, while preserving as much of the structure as possible.

Please note that proprietary binary xls format is not supported by this gem. If you need to parse those files, try spreadsheet gem.

To Install:

gem install rubyXL

To Use:

require 'rubyXL' # Assuming rubygems is already required

Convenience methods

Starting with version 3.4.0, the main data structure has been separated from the convenience methods that provide access to individual features of the xlsx format, in order to decrease the memory footprint. If you intend to use these features, you will need to additionally include the respective files:

require 'rubyXL/convenience_methods/cell'
require 'rubyXL/convenience_methods/color'
require 'rubyXL/convenience_methods/font'
require 'rubyXL/convenience_methods/workbook'
require 'rubyXL/convenience_methods/worksheet'

If you do not care about your RAM usage, just include them all at once by adding the following line to your code so it can continue operating just as before:

require 'rubyXL/convenience_methods'

Parsing an existing workbook

workbook = RubyXL::Parser.parse("path/to/Excel/file.xlsx")

Creating a new Workbook

workbook = RubyXL::Workbook.new

Accessing

Accessing a Worksheet

workbook.worksheets[0] # Returns first worksheet
workbook[0]            # Returns first worksheet
workbook['Sheet1']     # Finds and returns worksheet titled "Sheet1". Note that sheet names in Excel are limited to 31 character.

Accessing a Row (Array of Cells)¶ ↑

Please note that worksheet is a sparse array of rows. Your code must expect that any row it plucks from the array may be nil.

worksheet = workbook[0]
worksheet.sheet_data[0] # Returns first row of the worksheet
worksheet[0]            # Returns first row of the worksheet

Accessing a Cell object

Please note that row is a sparse array of cells. Your code must expect that any cell it plucks from the array may be nil.

worksheet = workbook[0]
worksheet.sheet_data[0][0] # Returns cell A1 in the worksheet
worksheet[0][0]            # Returns cell A1 in the worksheet

cell = worksheet[0][0]
cell.value                 # Returns a properly converted value in the cell (if the file claims that the cell
                           # is holding a number, returns a respective Integer or Float, and so on).

Or, if you prefer Excel-style references (single-cell only!)

cell = worksheet.cell_at('B11')

Wrappers for accessing Cell properties

cell = workbook[0][0][0]
cell.is_struckthrough  # Returns +true+ if the cell is struckthrough, other boolean properties have same syntax
cell.font_name
cell.font_size
cell.font_color
cell.fill_color
cell.horizontal_alignment
cell.vertical_alignment
cell.get_border(:top)
cell.get_border_color(:top)
cell.text_rotation

Wrappers for accessing Row properties 

Please note: these methods are being phased out in favor of the OOXML object model.

worksheet = workbook[0]
worksheet.get_row_fill(0)
worksheet.get_row_font_name(0)
worksheet.get_row_font_size(0)
worksheet.get_row_font_color(0)
worksheet.is_row_underlined(0)
worksheet.get_row_height(0)
worksheet.get_row_alignment(0, true)
worksheet.get_row_alignment(0, false)
worksheet.get_row_border(0, :right)
worksheet.get_row_border_color(0, :right)

Accessing column properties

Please note: these methods are being phased out in favor of the OOXML object model.

worksheet = workbook[0]
worksheet.get_column_fill(0)
worksheet.get_column_font_name(0)
worksheet.get_column_font_size(0)
worksheet.get_column_font_color(0)
worksheet.is_column_underlined(0)
worksheet.get_column_width(0)
worksheet.get_column_alignment(0, :horizontal)
worksheet.get_column_alignment(0, :vertical)
worksheet.get_column_border(0, :right)
worksheet.get_column_border_color(0, :right)

Modifying

Adding Worksheets

worksheet = workbook.add_worksheet('Sheet2')

Renaming Worksheets

worksheet.sheet_name = 'Cool New Name' # Note that sheet name is limited to 31 characters by Excel.

Adding Cells

worksheet.add_cell(0, 0, 'A1')      # Sets cell A1 to string "A1"
worksheet.add_cell(0, 1, '', 'A1')  # Sets formula in the cell B1 to '=A1'

Changing Cells¶ ↑

worksheet[0][0].change_contents("", worksheet[0][0].formula) # Sets value of cell A1 to empty string, preserves formula

Changing Fonts

worksheet.sheet_data[0][0].change_font_bold(true) # Makes A1 bold
worksheet.change_row_italics(0,true)              # Makes first row italicized
worksheet.change_column_font_name(0, 'Courier')   # Makes first column have font Courier

Changing Fills 

worksheet.sheet_data[0][0].change_fill('0ba53d')  # Sets A1 to have fill #0ba53d
worksheet.change_row_fill(0, '0ba53d')            # Sets first row to have fill #0ba53d
worksheet.change_column_fill(0, '0ba53d')         # Sets first column to have fill #0ba53d

Changing Borders

# Possible weights: hairline, thin, medium, thick
# Possible "directions": top, bottom, left, right, diagonal
worksheet.sheet_data[0][0].change_border(:top, 'thin')  # Sets A1 to have a top, thin border
worksheet.change_row_border(0, :left, 'hairline')       # Sets first row to have a left, hairline border
worksheet.change_column_border(0, :diagonal, 'medium')  # Sets first column to have diagonal, medium border

# Set the border style first so there's something to color.
worksheet.change_row_border_color(0, :top, '0ba53d')    # Sets first row to have a green top border
worksheet.change_column_border_color(0, :top, '0ba53d') # Sets first column to have a green top border

Changing Alignment

Horizontal

# Possible alignments: center, distributed, justify, left, right
worksheet.sheet_data[0][0].change_horizontal_alignment('center') # Sets A1 to be centered
worksheet.change_row_horizontal_alignment(0, 'justify')          # Sets first row to be justified
worksheet.change_column_horizontal_alignment(0, 'right')         # Sets first column to be right-aligned

Vertical

# Possible alignments: bottom, center, distributed, top
worksheet.sheet_data[0][0].change_vertical_alignment('bottom')  # Sets A1 to be bottom aligned
worksheet.change_row_vertical_alignment(0, 'distributed')       # Sets first row to be distributed vertically
worksheet.change_column_vertical_alignment(0, 'top')            # Sets first column to be top aligned

Rotation

# Possible values:
# * 0-90 - degrees counterclockwise, around the bottom LEFT corner of the cell;
# * 91-179 - degrees clockwise, around the bottom RIGHT corner of the cell;
# * 180-254 - degrees clockwise, around the bottom LEFT corner of the cell, text becomes progressively invisible
# * 255 - text is in normal rotation but displayed vertically (one letter under another), line feed starts new line to the right of the previous.
worksheet.sheet_data[0][0].change_text_rotation(90)  # Sets A1 to be rotated by 90 degrees

Changing Row Height

worksheet.change_row_height(0, 30)  # Sets first row height to 30

Changing Column Width

worksheet.change_column_width(0, 30)  # Sets first column width to 30

Merging Cells

worksheet.merge_cells(0, 0, 1, 1)  # Merges A1:B2

Insert Row

This method will insert a row at specified index, pushing all rows below it down. It also copies styles from row above.

WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted rows

worksheet.insert_row(1)

Insert Column

This method will insert a column at specified index, pushing all columns to the right of it one to the right. It also copies styles from column to the left

WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted columns

worksheet.insert_column(1)

Delete Row

This method will delete a row at specified index, pushing all rows below it up.

WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted rows

worksheet.delete_row(1)

Delete Column

This method will delete a column at specified index, pushing all columns to the right of it left.

WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted columns

worksheet.delete_column(1)

Insert Cell

This method will insert a cell at specified position. It takes a :right or :down option, to shift cells either left or down upon inserting (nil means replacing the cell)

WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted cells

worksheet.insert_cell(0, 0, "blah", formula = nil, :right)  # Inserts cell at A1, shifts cells in first row right
worksheet.insert_cell(0, 0, "blah", formula = nil, :down)   # Inserts cell at A1, shifts cells in first column down
worksheet.insert_cell(0, 0, "blah")                         # Inserts cell at A1, shifts nothing

Delete Cell

This method will delete a cell at specified position. It takes a :left or :up option, to shift cells either up or left upon deletion (nil means simply deleting the cell contents)

WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted cells

worksheet.delete_cell(0, 0, :left)  # Deletes A1, shifts contents of first row left
worksheet.delete_cell(0, 0, :up)    # Deletes A1, shifts contents of first column up
worksheet.delete_cell(0, 0)         # Deletes A1, does not shift cells

Modifying Cell Format

cell = worksheet[0][0]
cell.set_number_format '0.0000%'    # For formats, see https://support.office.com/en-us/article/5026bbd6-04bc-48cd-bf33-80f18b4eae68
cell.change_text_wrap(true)         # Makes the text in the cell to wrap.
cell.change_shrink_to_fit(true)     # Makes the text in the cell to shrink to fit.
cell.change_text_indent(1)          # Indents the text in the cell by 1 level

Add hyperlink to a Cell

cell.add_hyperlink('http://example.com')
cell.add_hyperlink('http://example.com', 'Some tooltip text')

I/O

By default, the gem operates with files on the local filesystem:

workbook = RubyXL::Parser.parse("path/to/Excel/file.xlsx")
workbook.write("path/to/desired/Excel/file.xlsx")

It can also operate on StringIO objects, thus eliminating the need to save the xlsx file to disk. This capability comes in handy for web servers.

workbook = RubyXL::Parser.parse_buffer(buffer)
workbook.stream

Miscellaneous

RubyXL::Reference.ind2ref(0,0) == 'A1'    # Converts row and column index to Excel-style cell reference
RubyXL::Reference.ref2ind('A1') == [0, 0] # Converts Excel-style cell reference to row and column index

Suppress warnings about malformed input files

RubyXL.class_variable_set(:@@suppress_warnings, true)

Data validation (colloquially referred to as “dropdown list”)

worksheet.add_validation_list("A1", [ "value1", "value2" ])

For more information

Take a look at the files in spec/lib/ for rspecs on most methods

Contributing to rubyXL

Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

Fork the project

Start a feature/bugfix branch

Commit and push until you are happy with your contribution

Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright © 2011 Vivek Bhagwat, 2013-2022 Wesha. See LICENSE.txt for further details.

Author: Weshatheleopard
Source Code: https://github.com/weshatheleopard/rubyXL 
License: MIT license

#ruby #excel 

RubyXL: Ruby Lib for Reading/writing/modifying .xlsx and .xlsm Files
Royce  Reinger

Royce Reinger

1657516200

Roo::Xls Add Support for Legacy Excel File Standards to Roo

Roo::Xls

This library extends Roo to add support for handling class Excel files, including:

  • .xls files
  • .xml files in the SpreadsheetML format (circa 2003)

There is no support for formulas in Roo for .xls files - you can get the result of a formula but not the formula itself.

Limitations

Roo::Xls currently doesn't provide support for the following features in Roo:

Installation

Add this line to your application's Gemfile:

gem 'roo-xls'

And then execute:

$ bundle

Or install it yourself as:

$ gem install roo-xls

Usage

TODO: Write usage instructions here

Contributing

  1. Fork it ( https://github.com/roo-rb/roo-xls/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Author: Roo-rb
Source Code: https://github.com/roo-rb/roo-xls 
License: MIT license

#ruby #excel #file 

Roo::Xls Add Support for Legacy Excel File Standards to Roo
Royce  Reinger

Royce Reinger

1657508820

Roo Provides an interface to Spreadsheets Of Several Sorts

Roo

Roo implements read access for all common spreadsheet types. It can handle:

  • Excel 2007 - 2013 formats (xlsx, xlsm)
  • LibreOffice / OpenOffice.org formats (ods)
  • CSV
  • Excel 97, Excel 2002 XML, and Excel 2003 XML formats when using the roo-xls gem (xls, xml)
  • Google spreadsheets with read/write access when using roo-google

Installation

Install as a gem

$ gem install roo

Or add it to your Gemfile

gem "roo", "~> 2.9.0"

Usage

Opening a spreadsheet

require 'roo'

xlsx = Roo::Spreadsheet.open('./new_prices.xlsx')
xlsx = Roo::Excelx.new("./new_prices.xlsx")

# Use the extension option if the extension is ambiguous.
xlsx = Roo::Spreadsheet.open('./rails_temp_upload', extension: :xlsx)

xlsx.info
# => Returns basic info about the spreadsheet file

Roo::Spreadsheet.open can accept both paths and File instances.

Working with sheets

ods.sheets
# => ['Info', 'Sheet 2', 'Sheet 3']   # an Array of sheet names in the workbook

ods.sheet('Info').row(1)
ods.sheet(0).row(1)

# Set the last sheet as the default sheet.
ods.default_sheet = ods.sheets.last
ods.default_sheet = ods.sheets[2]
ods.default_sheet = 'Sheet 3'

# Iterate through each sheet
ods.each_with_pagename do |name, sheet|
  p sheet.row(1)
end

Accessing rows and columns

Roo uses Excel's numbering for rows, columns and cells, so 1 is the first index, not 0 as it is in an Array

sheet.row(1)
# returns the first row of the spreadsheet.

sheet.column(1)
# returns the first column of the spreadsheet.

Almost all methods have an optional argument sheet. If this parameter is omitted, the default_sheet will be used.

sheet.first_row(sheet.sheets[0])
# => 1             # the number of the first row
sheet.last_row
# => 42            # the number of the last row
sheet.first_column
# => 1             # the number of the first column
sheet.last_column
# => 10            # the number of the last column

Accessing cells

You can access the top-left cell in the following ways

sheet.cell(1,1)
sheet.cell('A',1)
sheet.cell(1,'A')
sheet.a1

# Access the second sheet's top-left cell.
sheet.cell(1,'A',sheet.sheets[1])

Querying a spreadsheet

Use each to iterate over each row.

If each is given a hash with the names of some columns, then each will generate a hash with the columns supplied for each row.

sheet.each(id: 'ID', name: 'FULL_NAME') do |hash|
  puts hash.inspect
  # => { id: 1, name: 'John Smith' }
end

Use sheet.parse to return an array of rows. Column names can be a String or a Regexp.

sheet.parse(id: /UPC|SKU/, qty: /ATS*\sATP\s*QTY\z/)
# => [{:id => 727880013358, :qty => 12}, ...]

Use the :headers option to include the header row in the parsed content.

sheet.parse(headers: true)

Use the :header_search option to locate the header row and assign the header names.

sheet.parse(header_search: [/UPC*SKU/,/ATS*\sATP\s*QTY\z/])

Use the :clean option to strip out control characters and surrounding white space.

sheet.parse(clean: true)

Options

When opening the file you can add a hash of options.

expand_merged_ranges

If you open a document with merged cells and do not want to end up with nil values for the rows after the first one.

xlsx = Roo::Excelx.new('./roo_error.xlsx', {:expand_merged_ranges => true})

Exporting spreadsheets

Roo has the ability to export sheets using the following formats. It will only export the default_sheet.

sheet.to_csv
sheet.to_matrix
sheet.to_xml
sheet.to_yaml

Excel (xlsx and xlsm) Support

Stream rows from an Excelx spreadsheet.

xlsx = Roo::Excelx.new("./test_data/test_small.xlsx")
xlsx.each_row_streaming do |row|
  puts row.inspect # Array of Excelx::Cell objects
end

By default blank cells will be excluded from the array. To keep them, use the option pad_cells = true. (They will be set to nil in the array)

xlsx.each_row_streaming(pad_cells: true) do |row|
  puts row.inspect # Array of Excelx::Cell objects
end

To stream only some of the rows, you can use the max_rows and offsetoptions.

xlsx.each_row_streaming(offset: 1) do |row| # Will exclude first (inevitably header) row
  puts row.inspect # Array of Excelx::Cell objects
end
xlsx.each_row_streaming(max_rows: 3) do |row| # Will yield 4 rows (it's automatically incremented by 1) after the supplied offset.
  puts row.inspect # Array of Excelx::Cell objects
end

Iterate over each row

xlsx.each_row do |row|
  ...
end

Roo::Excelx also provides these helpful methods.

xlsx.excelx_type(3, 'C')
# => :numeric_or_formula

xlsx.cell(3, 'C')
# => 600000383.0

xlsx.excelx_value(row,col)
# => '600000383'

xlsx.formatted_value(row,col)
# => '0600000383'

Roo::Excelx can access celltype, comments, font information, formulas, hyperlinks and labels.

xlsx.comment(1,1, ods.sheets[-1])
xlsx.font(1,1).bold?
xlsx.formula('A', 2)

OpenOffice / LibreOffice Support

Roo::OpenOffice has support for encrypted OpenOffice spreadsheets.

# Load an encrypted OpenOffice Spreadsheet
ods = Roo::OpenOffice.new("myspreadsheet.ods", password: "password")

Roo::OpenOffice can access celltype, comments, font information, formulas and labels.

ods.celltype
# => :percentage

ods.comment(1,1, ods.sheets[-1])

ods.font(1,1).italic?
# => false

ods.formula('A', 2)

CSV Support

# Load a CSV file
csv = Roo::CSV.new("mycsv.csv")

Because Roo uses the standard CSV library, you can use options available to that library to parse csv files. You can pass options using the csv_options key.

For instance, you can load tab-delimited files (.tsv), and you can use a particular encoding when opening the file.

# Load a tab-delimited csv
csv = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"})

# Load a csv with an explicit encoding
csv = Roo::CSV.new("mycsv.csv", csv_options: {encoding: Encoding::ISO_8859_1})

You can also open csv files through the Roo::Spreadsheet class (useful if you accept both CSV and Excel types from a user file upload, for example).

# Load a spreadsheet from a file path
# Roo figures out the right parser based on file extension
spreadsheet = Roo::Spreadsheet.open(csv_or_xlsx_file)

# Load a csv and auto-strip the BOM (byte order mark)
# csv files saved from MS Excel typically have the BOM marker at the beginning of the file
spreadsheet = Roo::Spreadsheet.open("mycsv.csv", { csv_options: { encoding: 'bom|utf-8' } })

Upgrading from Roo 1.13.x

If you use .xls or Google spreadsheets, you will need to install roo-xls or roo-google to continue using that functionality.

Roo's public methods have stayed relatively consistent between 1.13.x and 2.0.0, but please check the Changelog to better understand the changes made since 1.13.x.

Contributing

Features

  1. Fork it ( https://github.com/roo-rb/roo/fork )
  2. Install it (bundle install --with local_development)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'My new feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Testing

Roo uses Minitest and RSpec. The best of both worlds! Run bundle exec rake to run the tests/examples.

You can run the tests/examples with Rspec like reporters by running USE_REPORTERS=true bundle exec rake

Roo also has a few tests that take a long time (5+ seconds). To run these, use LONG_RUN=true bundle exec rake

Issues

If you find an issue, please create a gist and refer to it in an issue (sample gist). Here are some instructions for creating such a gist.

  1. Create a gist with code that creates the error.
  2. Clone the gist repo locally, add a stripped down version of the offending spreadsheet to the gist repo, and push the gist's changes master.
  3. Paste the gist url here.

Author: roo-rb
Source Code: https://github.com/roo-rb/roo 
License: MIT license

#ruby #spreadsheets #excel 

Roo Provides an interface to Spreadsheets Of Several Sorts
Royce  Reinger

Royce Reinger

1657501440

Spreadsheet: The Ruby Spreadsheet By Ywesee GmbH

Spreadsheet

Description

The Spreadsheet Library is designed to read and write Spreadsheet Documents. As of version 0.6.0, only Microsoft Excel compatible spreadsheets are supported. Spreadsheet is a combination/complete rewrite of the Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.

Notes from Users

  • Alfred: The library doesn't recognize cell formats in Excel created documents, which results in Floats returned for any number.
  • Tom: This library only supports XLS format; it does not support XLSX format.

What's new?

  • Supported outline (grouping) functions
  • Significantly improved memory-efficiency when reading large Excel Files
  • Limited Spreadsheet modification support
  • Improved handling of String Encodings

On the Roadmap

  • Improved Format support/Styles
  • Document Modification: Formats/Styles
  • Formula Support
  • Document Modification: Formulas
  • Write-Support: BIFF5
  • Remove backward compatibility code

Note: Spreadsheet is tested against all minor ruby versions through: 1.8.7 - 2.6.3

You will get a deprecated warning about iconv when using spreadsheet with Ruby 1.9.3. So replacing iconv is on the Roadmap as well ;).

Dependencies

Examples

Installation

Using RubyGems:

  • sudo gem install spreadsheet

If you don't like RubyGems, let me know which installation solution you prefer and I'll include it in the future.

Tu build the gem you can do:

  • gem build spreadsheet

The gem package is built in pkg directory.

Testing

Bundler support added. Running tests:

  • bundle install
  • ./test/suite.rb

Getting Started

The Mailing List can be found here:

http://groups.google.com/group/rubyspreadsheet

The code can be found here:

https://github.com/zdavatz/spreadsheet

For Non-GPLv3 commercial licensing, please see:

http://www.spreadsheet.ch

XLS Binary Documentation

Authors

Original Code:

Spreadsheet::Excel: Copyright (c) 2005 by Daniel J. Berger (djberg96@gmail.com)

ParseExcel: Copyright (c) 2003 by Hannes Wyss (hannes.wyss@gmail.com)

New Code: Copyright (c) 2010 ywesee GmbH (ngiger@ywesee.com, mhatakeyama@ywesee.com, zdavatz@ywesee.com)

Author: zdavatz
Source Code: https://github.com/zdavatz/spreadsheet 
License: GPL-3.0 license

#ruby #excel #spreadsheets 

Spreadsheet: The Ruby Spreadsheet By Ywesee GmbH

CakeExcel: A Plugin to Generate Excel Files with CakePHP

CakeExcel

A plugin to generate Excel files with CakePHP.

Requirements

  • CakePHP 3.x
  • PHP 5.4.16 or greater
  • Patience

Installation

[Using Composer]

composer require dakota/cake-excel

Enable plugin

Load the plugin in your app's config/bootstrap.php file:

Plugin::load('CakeExcel', ['bootstrap' => true, 'routes' => true]);

Usage

First, you'll want to setup extension parsing for the xlsx extension. To do so, you will need to add the following to your config/routes.php file:

# Set this before you specify any routes
Router::extensions('xlsx');

Next, we'll need to add a viewClassMap entry to your Controller. You can place the following in your AppController:

public $components = [
    'RequestHandler' => [
        'viewClassMap' => [
            'xlsx' => 'CakeExcel.Excel',
        ],
    ]
];

Each application must have an xlsx layout. The following is a barebones layout that can be placed in src/Template/Layout/xlsx/default.ctp:

<?= $this->fetch('content') ?>

Finally, you can link to the current page with the .xlsx extension. This assumes you've created an xlsx/index.ctp file in your particular controller's template directory:

$this->Html->link('Excel file', ['_ext' => 'xlsx']);

Inside your view file you will have access to the PHPExcel library with $this->PhpExcel. Please see the PHPExcel documentation for a guide on how to use PHPExcel.

Author: Dakota
Source Code: https://github.com/dakota/CakeExcel 
License: MIT license

#php #cakephp #excel 

CakeExcel: A Plugin to Generate Excel Files with CakePHP
Gunjan  Khaitan

Gunjan Khaitan

1657074167

Learn Advanced Excel Online | Excel Tutorial For Beginners

Advanced Excel Full Course | Advance Excel Course | Excel Tutorial For Beginners 

This video on Advanced Excel Course by simplilearn is based on the latest and current Excel skills, techniques, tips, and tricks required by business analysts and data analysts in their day-to-day analytics. This course is developed in collaboration with real-time industry experts and major analytics giants to make sure the learners are given a chance to explore the world of data analytics and work with the advanced excel tricks to make things easier in day-to-day analytics is based on the Advanced Excel Tutorial for 2022. This Advanced Excel Course will cover the major fundamentals of Excel and its Advanced Excel concepts as well. This updated tutorial is dedicatedly designed and organized to help both beginners and experienced update and enhance their advanced excel skill set.

The advanced excel course covers the following

Excel Basic Knowledge 
How To Lock(Protect) Cells In Excel
Excel Print Page Setup
Goal Seek In Excel 
Charts In Excel
Conditional Formatting In Excel 
Data Validation In Excel 
Excel Lookup Functions - Vlookup, Hlookup, Xlookup 
How to implement Vstack Function In Excel
Excel Power Query Tutorial For Beginners
How To Convert PDF To Excel 
Excel Round Off Formula
Combining Data From Multiple Cells In Excel
DateDif In Excel 
How To Change Date Format In Excel (dd/mm/yyyy) To (mm/dd/yyyy) 
Pivot Tables In Excel 
How to Create a Pivot Table Using Multiple Sheets in Excel
Slicers In Excel
SUMIFS Formula in Excel
How to Create Drop Down List In Excel? 
Excel Budget Template 
Excel MIS Report 
Excel Macros And VBA For Beginners 
Userform In Excel
Regression In Excel
How To Recover Unsaved Excel File 
Project Planning 
Excel Tips And Tricks 2021
Excel Interview Questions And Answers


#excel

Learn Advanced Excel Online | Excel Tutorial For Beginners

How to Use VLOOKUP in Excel

When you're working in Excel, the VLOOKUP function makes looking up information less time-consuming. This is particularly true when you're using more than one Excel sheet.

In this article, you will learn what the VLOOKUP function does, as well as understand the syntax behind it. You will also learn how to use the VLOOKUP Excel function to search for a value with the help of a simple example.

Let's get started!

See more at: https://www.freecodecamp.org/news/how-to-use-vlookup-in-excel/

#excel 

How to Use VLOOKUP in Excel

如何在 Excel 中使用 VLOOKUP

当您在 Excel 中工作时,VLOOKUP 功能可以减少查找信息的时间。当您使用多个 Excel 工作表时尤其如此。

在本文中,您将了解 VLOOKUP 函数的作用,并了解其背后的语法。您还将通过一个简单的示例学习如何使用 VLOOKUP Excel 函数来搜索值。

让我们开始吧!

Excel 中的 VLOOKUP 是什么?VLOOKUP 定义

VLOOKUP 是一个强大的 Microsoft Excel 功能,可以从数据表中搜索和检索信息。

VLOOKUP 代表Vertical Lookup,因此 VLOOKUP 中的 V 是 Vertical 的缩写。

Excel 中的垂直是指列,在这种情况下,是指在电子表格中垂直查找数据。

具体来说,VLOOKUP 在列中查找特定值。

VLOOKUP 在数据集中查找特定信息,并返回与该初始信息相关但来自同一行的不同列的附加数据。

例如,如果您有一个姓名和电子邮件列表,VLOOKUP 将在表格中查找一个人的姓名并检索他们的电子邮件。这将是与他们的姓名相关联的电子邮件条目。

需要注意的是,VLOOKUP 不应与 HLOOKUP 混淆 - HLOOKUP 是一个完全不同的函数。

HLOOKUP 代表 Horizo​​ntal Lookup,H 是 Horizo​​ntal 的缩写。Excel 中的水平是指行和在电子表格中水平搜索数据。

要了解有关 Excel 中行和列的更多信息,请阅读解释两者之间区别的快速 quide 。

VLOOKUP 函数语法分解

VLOOKUP 函数的一般语法如下:

=VLOOKUP(lookup_value, table_array, column_number, [range_lookup])

首先编写一个等号,=然后键入VLOOKUP()函数。

VLOOKUP 函数有四个参数,每个参数用逗号分隔,,.

让我们解释一下每个参数的含义:

  • lookup_value:此参数是必需的,指定要查找和定位的值。该值位于表格的最左角和第一列。VLOOKUP 将始终搜索此右侧的信息lookup_value。
  • table_array:此参数是必需的,表示您要搜索的表中的数据范围。你想要得到的 the 、 the 和返回值都包含在这个范围内lookup_value。column_number
  • column_number:此参数是必需的。它是一个整数,指定table_array要从中检索返回值的列号。
  • range_lookup:此参数是可选的,并且是TRUEor FALSE。TRUE指定函数应该返回一个近似匹配,这意味着如果没有精确匹配,它应该返回可能的最接近的匹配。并FALSE指定该函数应返回与您要查找的内容完全匹配的内容,如果不返回,则会导致错误。

如何在 Excel 中使用 VLOOKUP

下面我有一个简单数据集的示例。

此示例将让您了解如何使用 VLOOKUP 函数。您还可以将此处使用的技术应用于更大、更复杂的表。

屏幕截图 2022-06-29-at-10.06.00-AM

我将使用 VLOOKUP 搜索员工数据表。此表存储员工的姓名、身份证号、他们工作的部门以及他们的薪水。

我想使用 VLOOKUP 搜索特定员工并返回匹配的工资。

我想要它,以便每当我在F2单元格中搜索员工的姓名时,都会返回他们相应的薪水。

所以,如果我想找到员工John Doe并返回他们的工资,在列中F2,我会写:

=VLOOKUP(A3, A2:D5, 4, FALSE)

让我们分解一下:

  • 该单元格A3包含我要搜索的值。命名的员工John Doe位于单元格中A3。这将是函数的查找值和第一个参数。
  • 单元格范围A2:D5包含我要搜索的数据。这是 VLOOKUP 将使用的数据源。这个范围需要包括第一列,它存储第一个参数,还需要包括我希望存储返回值的列。
  • 接下来,我包括可以找到返回值的列号。请记住,您需要从表格开始的位置开始计算。在这种情况下,它是4表中的第 th 列。
  • 最后,我希望 VLOOKUP 返回完全匹配,所以最后一个参数是FALSE.

然后我在单元格中看到结果F2:

截图-2022-07-01-at-5.13.50-PM

结论

在本文中,您了解了在 Excel 中使用 VLOOKUP 函数的基础知识。

谢谢阅读!

来源:https ://www.freecodecamp.org/news/how-to-use-vlookup-in-excel/

#excel 

如何在 Excel 中使用 VLOOKUP