블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2731)
Unity3D (814)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
03-28 00:02

[링크] https://blog.naver.com/kbnavi/220063172641

 

엑셀 중복체크 간단하게 처리하기(조건부서식, COUNTIF함수)

안녕하세요. 점심으로 순대국을 시원하게 해치운 백넘버9 입니다. 오전부터 친구녀석이 엑셀에서 중복체크...

blog.naver.com

 

반응형
Posted by blueasa
, |

[링크] https://blog.naver.com/good_ray/221538398631

 

[excel] Mysql for Excel 사용해보기

Mysql과 엑셀의 정보를 공유하며 데이터를 다룰 수 있는 프로그램이 여러개 있습니다. 저는 엑셀 2012부터...

blog.naver.com

 

반응형
Posted by blueasa
, |

유료라서 우선 Keep

 

[Link] https://www.xlcompare.com/

 

xlCompare - Compare and Merge Microsoft Excel Workbooks and VBA Projects

This powerful feature allows to perform any action in the command line mode, that could be programmed. It is suitable for complex cases, for example: when you need to compare several files at one run. Only a small set of the possible actions is described b

www.xlcompare.com

 

반응형
Posted by blueasa
, |

[파일] 

unity-excel-importer-master.zip


Unity Excel Importer

Automatically import from xls, xlsx to custom ScriptableObject in Unity Editor

Import Setup

1. Create Excel and add to Unity

Create an Excel file, make the first row the name of the column, and enter the data from the second row. And add it to Unity’s Project view.

create_excel import_excel_to_unity

2. Create Entity Class Script

Create a new script and define a class with Excel column names and public fields of the desired type. Also give the class ‘System.Serializable’ attribute.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class MstItemEntity
{
	public int id;
	public string name;
	public int price; 
}

3. Create Excel Asset Script

After selecting Excel, execute ExcelAssetScript from the Create menu and create a ScriptableObject script for Excel.

create_excel_asset

As for the generated script, the Excel file name and the sheet name are extracted and the part is commented out as below.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExcelAsset]
public class MstItems : ScriptableObject
{
	//public List<EntityType> Entities; // Replace 'EntityType' to an actual type that is serializable.
}

4. Replace EntityType in created Excel Asset

Uncomment fields and replace the generic type of List with the Entity class defined above.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExcelAsset]
public class MstItems : ScriptableObject
{
	public List<MstItemEntity> Entities;
}

4. Reimport or re-save Excel

When you import or re-save Excel, a ScriptableObject with the same name as Excel is created in the same directory and the contents of Excel are imported.

reimport_excel imported_entities

After this setting, updating Excel automatically updates ScriptableObject as well.

Advanced

Comment Row

If you enter ‘#’ in the first cell of the row, you can treat it as a comment and skip.

Change Asset Path

You can change the ScriptableObject generation position by specifying AssetPath as the ExcelAssetAttribute as shown below.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExcelAsset(AssetPath = "Resources/MasterData")]
public class MstItems : ScriptableObject
{
	public List<MstItemEntity> Entities;
}

Use Enum

You can use enum by entering the element name as string in cell. It is also useful to set Data Validation pull down as an element of enum in Excel.

Lisence

This library is under the MIT License. This software includes the work that is distributed in the Apache License 2.0.



[출처] https://unitylist.com/p/28t/Unity-excel-importer

반응형

'Unity3D > Plugins' 카테고리의 다른 글

[펌] Socket.io-Client for Unity3D 소개  (0) 2019.03.08
[링크] iOSPlugin Sample  (0) 2019.01.29
[링크] Emoji_Extension  (0) 2018.06.07
[펌] Background Worker for Unity3D  (0) 2018.06.01
[Link] UnityAppNameLocalizationForIOS  (0) 2018.03.27
Posted by blueasa
, |

[주의] 레지스트리를 수정하는 내용이니 주의해서 사용하세요.



C# 으로 OleDB를 이용해서 Excel을 읽어 들이고, Sqlite(.db)로 변환하는 Converter를 만들어서 사용하는 데


긴 문자열을 넣었더니 잘려서 컨버팅 되길래 확인해보니 255 글자 제한이 걸려 있다.


검색해서 확인해보니 여러가지 해결 방법들이 포스팅 돼 있는데 조금씩 안맞아서 확인해보고 정리해서 올려 놓는다.



[레지스트리 수정으로 255 글자 제한 풀기]


아래 버전 및 OS bit에 맞는 레지스트리를 찾아가서 TypeGuessRows 값을 0으로 바꾸면 된다.

(참고: 개발에 사용된 Excel 버전임. 윈도우 설치된 엑셀 버전이 아님)

(기본 값은 8인데, DataSet을 만들 때 기본으로 설정 된 윗 8줄에 있는 가장 큰 글자수를 DataType 길이로 잡는다고 한다.

 기본 글자 제한은 255자이고, 0으로 바꾸면 전체를 검사해서 DataType 길이로 잡는다고 함.)


[주의] 성능상의 이유로 글자수를 제한(Default:8) 하는 거라고 하니 감안해서 사용할 사람만 하기를..


  [Windowns 32bit]

Excel 2000, 2003 (xls)

  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel

  (Excel 97 = 3.5)


- Excel 2013 (xlsx)

  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Access Connectivity Engine\Engines\Excel

  (2016 = 16.0, 2013 = 15.0, 2010 = 14.0, 2007 = 12.0)


  [Windowns 64bit]

Excel 2000, 2003 (xls)

  HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel

  (Excel 97 = 3.5)


- Excel 2013 (xlsx)

  HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Access Connectivity Engine\Engines\Excel

 (2016 = 16.0, 2013 = 15.0, 2010 = 14.0, 2007 = 12.0)



[레지스트리 파일 다운로드]

Fix_255_Char_32bit_Excel_2000_2003.reg

Fix_255_Char_32bit_Excel_2007.reg

Fix_255_Char_32bit_Excel_2010.reg

Fix_255_Char_32bit_Excel_2013.reg


Fix_255_Char_64bit_Excel_2000_2003.reg

Fix_255_Char_64bit_Excel_2007.reg

Fix_255_Char_64bit_Excel_2010.reg

Fix_255_Char_64bit_Excel_2013.reg



    [Excel 데이터 수정으로 255 글자 제한 풀기] (확인 안해봤음)


- 위에도 적었지만 DataSet을 만들 때 기본으로 설정 된 윗 8줄에 있는 가장 큰 글자수를 DataType 길이로 잡는다고 한다.

  8줄 이내에 255 글자 이상의 사용하지 않는 Dummy 데이터를 넣으면 해결 된다고 함. 




[참조] http://www.todal.net/241?category=367351

[참조] http://it-developer.tistory.com/427

[참조] http://lemondory.tistory.com/129

[참조] http://ariswear.tistory.com/37

반응형
Posted by blueasa
, |

Link : http://ttend.tistory.com/249

반응형
Posted by blueasa
, |

xls와 xlsx 둘 다 되도록 예제를 약간 수정해서 테스트 완료.


P.s. 무슨 이유인지 모르지만 VS2013에서는 Microsoft.Office.Interop.Excel 이 없어서, 부득이하게 VS2010으로 작업함.

       (VS2012는 있는지 확인은 안해봤지만.. 얼핏 인터넷에서 보기로는 VS2012도 없는 듯..)

        
        private void CreateExcelFile()
        {
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object misValue = System.Reflection.Missing.Value;

            xlApp = new Excel.Application();
            // 생성할 때, 기본 Sheet 1개.
            xlWorkBook = xlApp.Workbooks.Add(misValue);

            // Sheet 추가.(필요한 Sheet 개수에 따라 루프 돌아야 될 듯)
            xlWorkBook.Worksheets.Add(misValue, misValue, misValue, misValue);

            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            // Sheet Name 지정.
            xlWorkSheet.Name = "SheetName1";
            xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com";

            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);
            xlWorkSheet.Name = "SheetName2";
            xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com";

            // 테스트용으로 파일명 직접 입력.
            string createFilePath = Directory.GetCurrentDirectory() + @"\" + "csharp-Excel.xlsx";

            // 파일 있으면 삭제.
            if (true == File.Exists(createFilePath))
            {
                File.Delete(createFilePath);
            }

            // 확장자만 검사하기 위해..
            string strExtension = Path.GetExtension(createFilePath);

            if (0 == strExtension.CompareTo(".xlsx"))
            {
                xlWorkBook.SaveAs(createFilePath, Excel.XlFileFormat.xlOpenXMLWorkbook, misValue, misValue, false, false, Excel.XlSaveAsAccessMode.xlNoChange, Excel.XlSaveConflictResolution.xlUserResolution, true, misValue, misValue, misValue);
            }
            else if (0 == strExtension.CompareTo(".xls"))
            {
                xlWorkBook.SaveAs(createFilePath, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            }

            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);

            MessageBox.Show("Excel file created , you can find the file " + createFilePath);
        }

        private void releaseObject(object obj)
        {
            try
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                obj = null;
            }
            catch (Exception ex)
            {
                obj = null;
                MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
            }
            finally
            {
                GC.Collect();
            }
        }



엑셀 생성 참조 : http://csharp.net-informations.com/excel/csharp-create-excel.htm

xlsx 참조 : http://stackoverflow.com/questions/9769703/exporting-to-xlsx-using-microsoft-office-interop-excel-saveas-error


반응형
Posted by blueasa
, |

C# Excel Tutorial

Programming/C# / 2014. 3. 26. 15:02
 C# Excel Tutorial


반응형
Posted by blueasa
, |


[제작자 황현우님의 파일]

LiAsExcelDB.cs


[개인적으로 필요해서 소스 좀 수정된 파일]

LiAsExcelDB.cs




C# 에서 Excel 로 데이터 기록 및 읽기 [OleDB]

 

OleDB 를 이용한 Excel 로 데이터베이스 처럼이용하기 입니다만...

Excel 을 제어하는 방법으로 사용해도 무방합니다. 저장이.. 1만건 이상일 때부터는 좀 느려지지만

(제 PC 에서는 한 2초 정도 걸리는 군효..) 읽기는 순식간입니다.

대량으로 저장할 때는 다른 방식으로 해야될 듯..

 

[참고] 요기 본문에 나오는 모든 소스는 첨부된 파일에 있으니, 복사해서 쓰지 마시고..

그리고 퍼가시거나 소스를 사용하신다면 댓글이라도 남겨주시는 센스도.. 사실 퍼가면 코딩하는

시간 버는 거니.. 댓글 다시는데 약간의 시간의 사용하셔도 쿨럭..ㅡ.,ㅡ;;

 

흠,.. C# 에서는 좀 사기적인(?) 지원이 많은 관계로.. 엄청 편리하네요.. 속도는 좀 떨어지만서도..

여튼,.. 프로그램을 만들때.. 매번 DB 를 쓰기도 그렇고.. 그렇다고 Access 쓰기도 구차니즘에

손가락이 떨려오신다면.. Excel 파일을 DB 처럼 사용하는 방법을 이용하는 것도 나름 좋은

방법입니다. 일단 내용의 보안이나 등등의 기능까지 하긴 너무 양이 많아 질꺼 같고..

최대한 간단하게 Excel 파일을 제어해서 Database 처럼 사용하는 방법을 살펴보죠..

(검색해보시면 비슷자료가 많이 있으니 다른 사람들의 것도 참고 하시는 것도 좋은 공부방법이죠..)

 

먼저 Excel 의 구조와 C# 의 DataSet 을 간단하게 살펴보면... 왠지 느낌이 팍! 하고 오실껍니다.

 

DataSet : 테이블의 집합

Excel : Sheet 의 집합 -> 즉, 하나의 시트가 DataSet 에 하나의 Table 이라고 생각하면 됩니다.

 

DataTable : 하나의 테이블 객체.. 컬럼과 줄이 존재하지요..

Sheet : 열과 행이 존재하지요.. 테이블로 보자면 컬럼과 줄..

 

그렇습니다.. -_-;; 이넘들이 개념이 같은 넘들이였습니다. (원래도 같은 넘들이였죠.. DOS 시절에..)

 



 

위와 같이 되는 거죠.. sheet 명이 table 명,  첫번째 줄의 데이터가 Field 명이 됩니다.

음.. 개념 잡기는 여기까지만 하고.. 본격적인 내용으로 들어가면...

 

[ Excel 파일 버전 검사 ]

 

Excel 파일이 버전에 따라서.. OleDB Connection String 이 다릅니다.

즉, xls 인지.. xlsx 인지에 따라서 다르게 처리해야 되는데...

기본적으로 확장명으로 비교할 수도 있겠지만.. 프로그램 만드는데 내부에서 쓰는 데이터 떡하니

xls 하기도 머시기 하고.. xxx 면 xls 라고 소스에서 비교할 수도 있겠지만.. 좀 아닌것 같아서

일단 확장명 상관없이 xls 인지 xlsx 인지 알아내는 방법을 보면... 아래처럼 2개가 있습니다.

 

A. Excel 를 연동해서 파일을 로딩.. 파일 정보를 본다.

B. Excel 파일을 열어서 맨 앞의 file header 부분을 본다.

 

A 로 하자니.. 실제로 두번 읽게 되니 -_-;; 글고 좀 느리구요.. B 로 해보겠습니다.

 

        public static int ExcelFileType(string XlsFile)
        { 

            // 요거이 비교할 파일 데이터 입니다.
            byte[,] ExcelHeader = {
                { 0xD0, 0xCF, 0x11, 0xE0, 0xA1 }, // XLS  File Header
                { 0x50, 0x4B, 0x03, 0x04, 0x14 }  // XLSX File Header
            };

            // result -2=error, -1=not excel , 0=xls , 1=xlsx
            int result = -1;

            FileInfo FI = new FileInfo(XlsFile);
            FileStream FS = FI.Open(FileMode.Open);

            try
            {
                byte[] FH = new byte[5];

                FS.Read(FH, 0, 5);

                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (FH[j] != ExcelHeader[i, j]) break;
                        else if (j == 4) result = i;
                    }
                    if (result >= 0) break;
                }
            }
            catch (Exception e)
            {
                result = (-2);
                //throw e;
            }
            finally
            {
                FS.Close();                
            }
            return result;
        }

 

와 같이 되겠습니다. 머.. 단순하죠.. 파일 열어서 5 byte 비교해서.. xls 인지 xlsx 인지..

excel 파일이 아닌지를 알아내는 것입니다.

 

[ OleDB Connection String ]

 

자.. 어느넘이 어느 넘인지 알았으니.. OleDB Connection String 을 만들어 봅시다요..

각 각 다음과 같습니다만.. 중요한 것만 내용에 넣었으니.. 필요한게 더 있으면 추가를...

아래의 형태는 string.Format 함수로 사용할 format 용 서식입니다.

 

        // 확장명 XLS (Excel 97~2003 용)
        private const string ConnectStrFrm_Excel97_2003 =
            "Provider=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=\"{0}\";" +
            "Mode=ReadWrite|Share Deny None;" +
            "Extended Properties='Excel 8.0; HDR={1}; IMEX={2}';" +
            "Persist Security Info=False";

 

        // 확장명 XLSX (Excel 2007 이상용)
        private const string ConnectStrFrm_Excel =
            "Provider=Microsoft.ACE.OLEDB.12.0;" +
            "Data Source=\"{0}\";" +
            "Mode=ReadWrite|Share Deny None;" +
            "Extended Properties='Excel 12.0; HDR={1}; IMEX={2}';" +
            "Persist Security Info=False";

 

중요한 건 Provider 가 무언지와 Extended Properties (<- 요게 Excel 파일에 대한 옵션) 입니다.

Extended 보면 HDR 과 IMEX 속성이 있는데 이것이 중요합니다.

HDR 은 Excel 의 첫번째 줄의 데이터를 Field 명으로 인식 할 것인지 여부 (YES , NO) 이고..

IMEX 는 데이터 형식을 어떻게 적용할 것인지 옵션인데, 만약 그 줄의 데이터의 표본이 정수라면

필드가 생성될 때 정수형으로 생성됩니다. 일단은 IMEX=1 로 해서 걍 무시하고 무조건 string 으로

하겠습니다. (다음 버전을 만든다면 속성까지 다 하는 방향으로..)

머.. 여기 까지 왔으면 사실 대부분 그냥 만드실 수 있겠지만.. 그래도 노가다를 줄이기 위해..

소스를 올려 놓겠습니다... (-o- ;)a

 

[ Excel 파일을 DataSet 으로.. ]

 

아.. 참고로.. Excel 파일을 DataSet 으로 바꾸는 순간만을 제외하면 Excel 파일을 사용하지

않습니다. 즉.. 메모리에 로딩한 다음 데이터가 바뀐다고 Excel 파일도 같이 수정되지는 않습니다.

읽을 때도.. 읽는 당시만, 저장할 때도 저장하는 당시만 파일에 lock 이 걸리고 그 전,후에는

엑셀 파일과 전혀~ 상관 안합니다.

 

    첨부된 소스의        

    private static DataSet OpenExcel(string FileName, bool UseHeader)

    를 참고해 주세요~

 

[ DataSet 을 Excel 파일로.. ]

 

    첨부된 소스의        

    private static bool SaveExcel(string FileName, DataSet DS, bool ExistDel, bool OldExcel)

    를 참고해 주세요~

 

첨부된 소스를 사용하실 꺼라면..

OpenExcelDB, SaveExcelDB 두개를 사용하세요..

 

나중에 소스 업데이트를 하면 OpenExcel 이랑 SaveExcel 는 내용이 변경될 것인지라..

업데이트된 소스로 엎어 쳤을 때 에러날 수 있습니다.

 

첨부된 Source 사용법은 다운 받은 소스를 Project 에 추가해 주시고...

사용할 소스의 using 절 부분에 아래줄 추가..

 

using LiAsExcelDatabase;

 

사용하는 것은 아래처럼 사용하시믄 됩니다..

 

                    DataSet DS = LiAsExcelDB.OpenExcelDB("C:\\Temp.xlsx");
                    LiAsExcelDB.SaveExcelDB("C:\\Temp_save.dat",DS);

 

질문이 있으시면.. 이 글의 답글로 남겨주시면 고맙겠습니다.



[출처] C# 에서 Excel 로 데이터 기록 및 읽기 [OleDB]|작성자 애쁠


반응형
Posted by blueasa
, |


링크 : http://istudy.tistory.com/75

반응형
Posted by blueasa
, |