안녕하세요 그레이프시티입니다.
문의주신 사항은 TextCellType의 ShrinkToFit 속성을 이용해서 설정이 가능합니다.
FarPoint.Win.Spread.CellType.TextCellType textCellType = new FarPoint.Win.Spread.CellType.TextCellType();
textCellType.ShrinkToFit = true;
fpSpread1.ActiveSheet.Cells[0, 0].CellType = textCellType;
혹은 아래와 같이 함수를 만들어 설정이 가능합니다.
public Form1()
{
InitializeComponent();
fpSpread1_Sheet1.Cells[1, 1].Value = "This is some string";
fpSpread1_Sheet1.Cells[1, 1].Font = GetAdjustedSize(1, fpSpread1_Sheet1.Cells[1, 1].Text, fpSpread1_Sheet1.Cells[1, 1].Font);
}
private Font GetAdjustedSize(int columnIn, string data, Font OriginalFont)
{
var GraphicRef = fpSpread1.CreateGraphics();
int MinFontSize = 2;
int MaxFontSize = 30;
float ContainerWidth = fpSpread1.ActiveSheet.Columns[columnIn].Width;
// We utilize MeasureString which we get via a control instance
for (int AdjustedSize = MaxFontSize; AdjustedSize >= MinFontSize; AdjustedSize--)
{
Font TestFont = new Font(OriginalFont.Name, AdjustedSize, OriginalFont.Style);
// Test the string with the new size
SizeF AdjustedSizeNew = GraphicRef.MeasureString(data, TestFont);
if (ContainerWidth > Convert.ToInt32(AdjustedSizeNew.Width))
{
// Good font, return it
return TestFont;
}
}
return OriginalFont;
}
다른 궁금한 점이 생기면, 언제든 문의 주시기 바랍니다.
감사합니다.
그레이프시티 드림
* 그레이프시티(GrapeCity)는 개발자를 위하여 ComponentOne(컴포넌트원), Spread(스프레드), ActiveReports(액티브리포츠), SpreadJS(스프레드JS), Wijmo(위즈모)와 같은 엑셀 스프레드시트 리포팅 그리드와 차트 등 다양한 종류의 .NET JavaScript(자바스크립트) 컴포넌트 툴을 생산하고있는 개발툴 전문 회사 입니다.