Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
370
VueRouterとNuxtのルーティング/VueRouter and Nuxt Routing
kkznch
0
330
Vuexで何を管理する方が良い?/What is better to store in Vuex?
kkznch
1
710
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.4k
Other Decks in Technology
See All in Technology
Kaggleふりかえり会〜LLM 20 Questions & ISIC 2024
recruitengineers
PRO
2
130
Bytebaseで実現する データベース管理の効率化
shogo452
2
350
Empowering Customer Decisions with Elasticsearch: From Search to Answer Generation
hinatades
PRO
0
240
品質管理チームのEMとして大事にしていること / QA EM
nihonbuson
0
400
プロダクトマネージャーは 事業責任者の夢をみるのか pmconf2024
gimupop
1
4.8k
クラウドネイティブへの小さな一歩!既存VMからコンテナまで、KubeVirtが実現する『無理しないペースの移行』とは!?
tsukaman
0
110
LangChainとSupabaseを活用して、RAGを実装してみた
atsushii
0
120
サービスの拡大に伴うオペレーション課題に立ち向かう / 20241128_cloudsign_pdm
bengo4com
0
870
「今までで一番学びになった瞬間」発表 LT - Shinjuku.rb #96
kozy4324
0
140
sre本読んだ感想
pisakun
0
200
システムリプレイスプロジェクト発足から7年、改めてコスト最適化に向き合う / replace and cost optimization
takumi
1
370
データカタログを自作したけど 運用しなかった話@Findy Lunch LT「データカタログ 事例から学ぶメタデータ管理の実態」
ryo_suzuki
2
630
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
243
12k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
GraphQLとの向き合い方2022年版
quramy
44
13k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Building an army of robots
kneath
302
43k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Being A Developer After 40
akosma
87
590k
Writing Fast Ruby
sferik
627
61k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Music & Morning Musume
bryan
46
6.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
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ΛͲ͏ͧ