티스토리 뷰
"NPOI.dll"을 이용한 엑셀 다운로드 방법.
public ActionResult DownloadExcel(string serviceNationCode, int qprimeTypeId, string originNationCode, string destinationNationCode)
{
int qprimeContractCompanyCode = GetQprimeContractCompanyCode(serviceNationCode, qprimeTypeId, originNationCode, destinationNationCode);
RateTable[] rateTableInfo = GetRateTable("DE", qprimeContractCompanyCode, "", "", "").ToArray();
var workbook = new HSSFWorkbook();
IFont boldFont = workbook.CreateFont();
boldFont.IsBold = true;
ICellStyle styleMiddle = workbook.CreateCellStyle();
styleMiddle.Alignment = HorizontalAlignment.Center;
styleMiddle.VerticalAlignment = VerticalAlignment.Center;
styleMiddle.WrapText = true;
styleMiddle.SetFont(boldFont);
styleMiddle.BorderBottom = BorderStyle.Thick;
var sheet = workbook.CreateSheet("Qprime Rate Table");
sheet.SetColumnWidth(0, 3500);
sheet.SetColumnWidth(1, 3500);
sheet.SetColumnWidth(2, 4000);
sheet.SetColumnWidth(3, 4000);
sheet.SetColumnWidth(4, 4000);
sheet.SetColumnWidth(5, 4000);
sheet.SetColumnWidth(6, 4000);
sheet.SetColumnWidth(7, 4000);
sheet.SetColumnWidth(8, 4000);
sheet.SetColumnWidth(9, 4000);
var headers = new[] { "Weight From (kg)", "Weight To (kg)", "Shipping Rate (SGD)", "Shipping Rate (KRW)", "Shipping Rate (JPY)", "Shipping Rate (MYR)", "Shipping Rate (IDR)", "Shipping Rate (USD)", "Shipping Rate (CNY)", "Shipping Rate (HKD)" };
var columns = new[] { "Weight From (kg)", "Weight To (kg)", "Shipping Rate (SGD)", "Shipping Rate (KRW)", "Shipping Rate (JPY)", "Shipping Rate (MYR)", "Shipping Rate (IDR)", "Shipping Rate (USD)", "Shipping Rate (CNY)", "Shipping Rate (HKD)" };
IRow headerRow = sheet.CreateRow(0);
headerRow.Height = 700;
ICell hearderCell = null;
for (int i = 0; i < columns.Length; i++)
{
hearderCell = headerRow.CreateCell(i);
hearderCell.CellStyle = styleMiddle;
hearderCell.SetCellValue(new HSSFRichTextString(headers[i]));
}
int rowIndex = 0;
IRow columnRow = null;
for (int i = 0; i < rateTableInfo.Length; i++)
{
rowIndex += 1;
columnRow = sheet.CreateRow(rowIndex);
columnRow.Height = 350;
columnRow.CreateCell(0).SetCellValue(CheckDecimal(rateTableInfo[i].WeightFrom).ToString());
columnRow.CreateCell(1).SetCellValue(CheckDecimal(rateTableInfo[i].WeightTo).ToString());
columnRow.CreateCell(2).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateSG).ToString());
columnRow.CreateCell(3).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateKR).ToString());
columnRow.CreateCell(4).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateJP).ToString());
columnRow.CreateCell(5).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateMY).ToString());
columnRow.CreateCell(6).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateID).ToString());
columnRow.CreateCell(7).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateUS).ToString());
columnRow.CreateCell(8).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateCN).ToString());
columnRow.CreateCell(9).SetCellValue(CheckDecimal(rateTableInfo[i].ShippingRateHK).ToString());
}
using (var memoryStream = new MemoryStream())
{
workbook.Write(memoryStream);
byte[] bytes = memoryStream.ToArray();
if (bytes.Length > 0)
{
return File(bytes, "application/vnd.ms-excel", "Qprime Reate Table.xls");
}
}
return View();
}
public ActionResult About()
{
return View();
}
public ActionResult RateTable()
{
return View();
}
}
- Total
- Today
- Yesterday
- await
- 메이븐(maven)
- MainActor
- nl2br
- System.Diagnostics
- React
- java web-mvc
- jstl(java standard tag library)-core
- 스프링 시큐리티(spring security)
- error-java
- In App Purchase
- java 키워드 정리
- 문자 자르기
- 스프링 프레임워크(spring framewordk)
- java.sql
- java-개발 환경 설정하기
- jstl(java standard tag library)
- system.io
- jsp 오픈 소스
- 진수 변환
- 인텔리제이(intellij)
- 람다식(lambda expression)
- 스프링 시큐리티(spring security)-http basic 인증
- REST API
- 표현 언어(expression language)
- 제품 등록
- 상품 등록
- 스프링 프레임워크(spring framework)
- 특정 문자를 기준으로 자르기
- .submit()
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |