Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
LaraCSVで手軽にCSVを出力する/Easily generate CSV by Lar...
Search
kkznch
May 16, 2019
Technology
0
1.6k
LaraCSVで手軽にCSVを出力する/Easily generate CSV by LaraCSV
Laravel Meetup宮崎
登壇枠で使用
参考URL
https://re-build.connpass.com/event/129466/
kkznch
May 16, 2019
Tweet
Share
More Decks by kkznch
See All by kkznch
黒い画面へようこそ/Hello, black screen
kkznch
0
360
VueRouterとNuxtのルーティング/VueRouter and Nuxt Routing
kkznch
0
320
Vuexで何を管理する方が良い?/What is better to store in Vuex?
kkznch
1
700
Firestoreのルール設定 割と何でも出来てビビる/Firestore rule setting
kkznch
1
720
自社サービス チャット機能にFirebaseが導入されてた/Firebase was introduced to the chat function of our service
kkznch
0
1.1k
SPA開発未経験者によるNuxt.jsを使った自社サービス開発 / Development of own service using Nuxt.js by inexperienced SPA development
kkznch
3
3.1k
Laravel Telescopeが便利そうな気がする/Laravel Telescope seems to be convenience
kkznch
1
1.1k
Laravel Novaはなんだかいい感じらしい/Laravel Nova seems to be nice
kkznch
0
610
Laravel5.5的 継続的インテグレーション / Laravel 5.5 Continuous Integration
kkznch
3
3.3k
Other Decks in Technology
See All in Technology
Can We Measure Developer Productivity?
ewolff
1
150
ドメイン名の終活について - JPAAWG 7th -
mikit
33
20k
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
140
[FOSS4G 2024 Japan LT] LLMを使ってGISデータ解析を自動化したい!
nssv
1
210
複雑なState管理からの脱却
sansantech
PRO
1
140
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
580
TypeScript、上達の瞬間
sadnessojisan
46
13k
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
530
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Facilitating Awesome Meetings
lara
50
6.1k
How GitHub (no longer) Works
holman
310
140k
Site-Speed That Sticks
csswizardry
0
24
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
860
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Raft: Consensus for Rubyists
vanstee
136
6.6k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Transcript
LaraCSVͰ खܰʹCSVΛग़ྗ͢Δ גࣜձࣾRe:Build Յ ါىʢ@kkznchʣ 20195݄16ʢʣ Laravel Meetup Miyazaki
͚͚ͣΜ @kkznch Յ ါى 1990ͷԭೄੜ·Ε ిྗձࣾͷITΠϯϑϥɺηΩϡϦςΟ ↓ גࣜձࣾRe:BuildͰWebΤϯδχΞ
ձࣾհ • גࣜձࣾRe:Buildʢ201711݄ʹઃཱʣ • ݱࡏͷࣾһ໊̑ • ԭೄΛڌͱ͠ɺجຊతʹLaravelVue.jsΛ ͬͯडୗɾࣗࣾαʔϏε։ൃΛ͍ͯ͠Δ • ϦϞʔτϫʔΫɺࣗ༝ͳಇ͖ํΛਪ͍ͯ͠Δ
LaraCSV
None
͍ํ
ϥΠϒϥϦΛՃ͢Δ # terminal͔ΒԼهͷίϚϯυΛ࣮ߦ͢Δ $ composer require usmanhalalit/laracsv:^2.0
CSVͷϏϧυ // ΠϯελϯεΛੜ͢Δ $csvExporter = new \Laracsv\Export(); // ୈҰҾʹCollectionΛɺ //
ୈೋҾʹCSVͰग़ྗ͍ͨ͠ϞσϧͷΧϥϜ໊Λೖྗ͢Δ $csvExporter->build(Users::get(), ['email', 'name']);
CSVͷμϯϩʔυ // μϯϩʔυ͢Δ $csvExporter->download(); email,name
[email protected]
,"Ԭ෦ ྙଠ"
[email protected]
,"໊ ·ΏΓ"
[email protected]
,"ڮా
ࢸ" // ϑΝΠϧ໊Λࢦఆͯ͠μϯϩʔυ͢Δ $csvExporter->download('users.csv');
ྑ͍ͱࢥͬͨͱ͜Ζ
ϦϨʔγϣϯऔಘ͢Δ // Ϟσϧʹఆٛ͞Ε͍ͯΔϦϨʔγϣϯΛࢦఆ͢Δ͚ͩ $csvExporter->build(Users::get(), ['email', 'name', ‘department.name’]);
ͷՃɾมߋ͕Ͱ͖Δ $csvExporter->beforeEach(function($user) { // طଘͷΛ্ॻ͖Ͱ͖Δ $user->email = '
[email protected]
'; // ଘࡏ͠ͳ͍ΛՃͰ͖Δ
$user->note = $user->name . 'ϝϞͰ͢'; }); $csvExporter->build(User::get(), [‘email', 'name', ‘note'])->download(); email,name,note
[email protected]
,"Ԭ෦ ྙଠ","Ԭ෦ ྙଠϝϞͰ͢"
[email protected]
,"໊ ·ΏΓ","໊ ·ΏΓϝϞͰ͢"
࣮Ͱͷ͍ॴʁ
͍ॴ • τϥϯβΫγϣϯσʔλͷCSVग़ྗ • ܭࢉ݁ՌΛ֨ೲͨ͠࿈ྻͷCSVग़ྗ ‣ ྻΛCollectionܕʹมͯ͢͠ͱಈ͘
CSVϥΠϒϥϦͷൺֱ
CSVϥΠϒϥϦ ͍Ζ͍Ζ͋Δ
Packalyst ʢCSVϥΠϒϥϦ DL߱ॱʣ
৮ΓͭͭΛൺֱͯ͠Έͨ
ൺֱର • laracsv • excel • laravel-formatter • fast-excel
࣮ݧ • string(255)ܕΧϥϜΛ10ݸ࣋ͭςʔϒϧ • Ϩίʔυ5120݅ • ֤ϥΠϒϥϦͰCSVϑΝΠϧΛग़ྗ͢Δ·Ͱ ͷ࣌ؒΛଌఆ͢Δ
݁Ռ ࣌ؒʢඵʣ ίϝϯτ MBSBDTW ͍͕͍উखΑ͍ FYDFM ग़ྗ͢ΔͨΊʹ&YQPSU༻ΫϥεΛ ༻ҙ͢Δඞཁ͕͋ͬͯ໘͍͘͞
MBSBWFMGPSNBUUFS ϑΥʔϚοτͷม͚ͩߦΘΕΔɻ ϑΝΠϧͷॻ͖ग़͠ཁࣗ࡞ GBTUFYDFM ଌఆϛεͬͨͷ͔ͳʜ ϫϯϥΠφʔͰ$47രग़ྗ
·ͱΊ
·ͱΊ • LaraCSVͰखܰʹCSVͷग़ྗ͕Ͱ͖Δ ‣ ग़ྗ͢ΔΧϥϜͷࢦఆ͕༰қ ‣ ϦϨʔγϣϯઌͷࢦఆͰ͖Δ • ͞Λٻ͢Δ͋ͳͨfast-excelΛͲ͏ͧ