반응형

입력한 날짜가 몇주차인지 구하는 방법이다.

 

DateTime targetDate = DateTime.Parse(txtdate.Value);

System.Globalization.CultureInfo culture = null;

if (culture == null)
{
    culture = System.Globalization.CultureInfo.CurrentCulture;
}

System.Globalization.CalendarWeekRule weekRule = culture.DateTimeFormat.CalendarWeekRule;
DayOfWeek firstDayOfWeek = culture.DateTimeFormat.FirstDayOfWeek;
int WeekOfYear = culture.Calendar.GetWeekOfYear(targetDate, weekRule, firstDayOfWeek);
WeekOfYear = WeekOfYear - 1;

 

각 문화권에 맞게 주차를 구하도록 되어 있다.

반응형
반응형

C# 에서 엑셀변환을 하면 <br> 로 인한 줄바꿈을 할때 한 셀 내에서 줄바꿈이 되지 않고 아래 셀로 줄바꿈이 일어나서

나중에 정렬할 때나 편집을 할 때 골치 아프게 된다.

 

이럴 때 아래와 같이 처리하면 한 셀 안에서 줄바꿈이 된다.

 

------------------------------------------------------

소스 .aspx.cs 파일에서는

.Replace("\n", "<BR style='mso-data-placement: same-cell;'>");

MS-SQL 쿼리에서 직접 줄바꿈을 추가하려면

'<BR>' 대신에 '<BR style="mso-data-placement: same-cell;">' 를 넣으면 됨

------------------------------------------------------

단 해당 셀의 wrap 는 true 여야 한다. (텍스트 줄바꿈 허용)

////oGridView.RowStyle.Wrap = false; //// 한 셀 안에서 줄바꿈을 할 때는 이 옵션을 사용하면 안 됨

반응형

+ Recent posts