Excel Export
데이타 그리드 뷰를 Excel로 내보내는 처리를 함.
아래는 OleDb를 이용해서 Excel파일을 만들어 그 내용을 저장하는
ExcelToExportClass 객체를 만들어서 사용하는 부분임.
추가적으로 프로그래스바를 지원하며
변환 중에 프로그래스바에 진행률을 전달하여 표시해줌.
void _Export()
{
ExcelToExportClass ex = new ExcelToExportClass();
ex.ExportStart = delegate(int max)
{
this.Invoke(prog.MaxInit, new object[] { max });
};
ex.Exporting = delegate()
{
this.Invoke(prog.Increment, new object[] { 1 });
};
ex.ExportEnd = delegate()
{
this.Invoke(prog.Hide);
MessageBox.Show("파일이 저장되었음.");
};
//ex.ExcelToExport(this.dataGridView3, DateTime.Now.ToString("HHmmss"));
ex.ExcelToExport(this.dataGridView3);
}
'# 2) .Net ( Vs 2005 ) > WinForm' 카테고리의 다른 글
그리드뷰 컨트롤 (0) | 2009.05.02 |
---|---|
SMS TextLength 비교 (0) | 2009.05.01 |
판넬 슬라이드 애니메이션 (0) | 2009.05.01 |
데이타베이스 브라우져 ver3 (0) | 2009.05.01 |
다각형 내부 클릭 체크. (0) | 2009.05.01 |
DB Connection Factory
DB연결객체과 Excel Access 연결객체를 만들어주는 놈을 만들었다.
/// <summary>
/// 연결 문자열 팩토리.
/// </summary>
public static class OleDbConnetionFactory
{
/*
Provider (OLE DB only)
Access : Microsoft.JET.OLEDB.4.0
Oracle - MSDAORA
MS SQL - SQLOLEDB
Data Source(server) : 데이터베이스 위치 (Domain or IPAddress)
Initial Catalog (database): 데이터 베이스 이름
User ID/Password : 인증 정보
*/
/// <summary>
/// MS-SQL 데이타 베이스 연결 문자열.
/// </summary>
/// <returns> 연결 문자열 </returns>
public static string MSSQLConnectionString()
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection appSetting = (AppSettingsSection)config.GetSection("AppSettings");
OleDbConnectionStringBuilder oleCon = new OleDbConnectionStringBuilder();
oleCon.Add("Provider", "SQLOLEDB");
oleCon.Add("Data Source", string.Format("{0}", "서버명"));
oleCon.Add("UID", "아이디");
oleCon.Add("PWD", "패스워드");
oleCon.Add("Database", "DB명");
return oleCon.ConnectionString;
}
/// <summary>
/// 엑셀-> 읽기, 쓰기관련 플래그 셋팅
/// </summary>
public enum Excel_Imex
{
/// <summary>
/// 읽기 적용
/// </summary>
Read = 1,
/// <summary>
/// 쓰기 적용.
/// </summary>
Write = 0
}
/// <summary>
/// 엑세스(Excel) 데이타 베이스 연결 문자열
/// </summary>
/// <param name="ExcelFilePath"></param>
/// <param name="imex"></param>
/// <returns> 연결 문자열 </returns>
public static string ExcelConnectionString(string ExcelFilePath, Excel_Imex imex)
{
OleDbConnectionStringBuilder oleCon = new OleDbConnectionStringBuilder();
oleCon.Add("Provider", "Microsoft.Jet.OLEDB.4.0");
oleCon.Add("Data Source", string.Format("{0}", ExcelFilePath));
oleCon.Add("Extended Properties", string.Format("Excel 8.0;imex={0};HDR=Yes", (int)imex));
return oleCon.ConnectionString;
}
}
'# 2) .Net ( Vs 2005 ) > 기타' 카테고리의 다른 글
PWD 암호화 객체. (0) | 2009.05.08 |
---|---|
인터페이스와델리게이트조합1 (2) | 2009.05.08 |
DB로컬 연결시 문구 (0) | 2009.05.02 |
큐브~ (0) | 2009.05.02 |
XML 컨트롤... (0) | 2009.05.02 |
판넬 슬라이드 애니메이션
판넬에 슬라이드 애니메이션을 구현한 것임.
참 간단하다.
브라우져에서 적용해보았고.
이에는 조금 특별한 레이아웃 기법이 필요하다.
양쪽 모두 처리 하기위해서...
// 타이머로 슬라이드 처리를 해주는 객체임.
internal class SlidePanel : IDisposable
{
Timer tm = new Timer();
int baseWidth = 0;
Control ctrl = null;
bool goRight = false;
int add = 0;
internal SlidePanel(Control _ctrl)
{
ctrl = _ctrl;
this.tm.Interval = 1000 / 23;
this.tm.Tick += new EventHandler(tm_Tick);
baseWidth = ctrl.Width;
goRight = true;
}
internal void Start()
{
SlideInit();
tm.Start();
}
internal void ReflashWidth( int width)
{
if( width >= 100)
baseWidth = width;
}
/// <summary>
/// 컨트롤이 작아진건지 커진건지 확인.
/// </summary>
internal bool ViewEnabled
{
get { return ctrl.Width > 10 ? true : false; }
}
private void SlideInit()
{
add = baseWidth / 23 * 6;
if (goRight)
{ add = -1 * (add); }
else
{ add = +1 * (add); }
if (this.tm.Enabled) this.tm.Stop();
this.tm.Start();
}
private void Stop()
{
this.tm.Stop();
goRight = !goRight;
}
void tm_Tick(object sender, EventArgs e)
{
ctrl.Width = ctrl.Width + (add);
if (goRight)
{
if (ctrl.Width <= 0)
this.Stop();
}
else
{
if (ctrl.Width >= baseWidth)
{
ctrl.Width = baseWidth;
this.Stop();
}
}
}
#region IDisposable 멤버
void IDisposable.Dispose()
{
if (tm.Enabled) tm.Stop();
this.tm.Dispose();
this.tm = null;
}
#endregion
}
'# 2) .Net ( Vs 2005 ) > WinForm' 카테고리의 다른 글
SMS TextLength 비교 (0) | 2009.05.01 |
---|---|
Excel Export (0) | 2009.05.01 |
데이타베이스 브라우져 ver3 (0) | 2009.05.01 |
다각형 내부 클릭 체크. (0) | 2009.05.01 |
프로시져 생성기 (0) | 2009.05.01 |