HAI
我想要使用POI API将单元格文本值转换为Excel中的数字.
单元格文本值,如'2,345',表示为数字.
我怎样才能做到这一点.
如果有人遇到这个问题,请告诉我...
我需要将一些(可能只是一个或多个)Microsoft图表导出为PDF和Excel.它需要在按钮单击时发生,图表应直接导出到PDF而不会呈现到网页上.
使用的环境:ASP.NET
请建议实现这一目标的方法.
干杯
将数据从数据库导出到Excel电子表格时,我很难正确显示帐号.一家公司的帐号正确显示.但是,其他人则没有.用户必须双击单元格才能查看整个帐号.我用谷歌搜索过这个问题,但我尝试过的解决方案都没有.
<cfsetting enablecfoutputonly="Yes">
<cfsavecontent variable="sTest">
<cfoutput>
<table>
<tr><th align="center">ATTUID</th>
<th>Company Name</th>
<th align="center">Account Number </th>
<th align="center">Total Past Due Balance</th>
<th align="center">Date Sent</th>
</tr>
<cfloop query="returnQuery">
<tr><td>#attuid#</td>
<td>#companyname#</??td>
<td>#AccountNum4#??</td>
<td>#totalpastd??ue#</td>
<td>#datefor??mat(posted)# #timeformat(posted, "h:mm tt")#</td>
</tr>
</cfloop>
</table>
</cfoutput>
</cfsavecontent>
<cfcontent type="application/vnd.msexcel">
<cfheader name="Content-Disposition" value="inline; filename=export.xls">
<cfoutput>#sTest#</cfoutput>
Run Code Online (Sandbox Code Playgroud) 我有一个库可以将VCL网格的内容导出为XLS格式.(不确定哪个版本的XLS格式;这是问题的一部分.)它通常可以正常工作,但在某些情况下,当我在Excel 2007中打开由此库导出的XLS时,它说"Excel找到了不可读的内容'[myfile.xls]'.你想恢复这个工作簿的内容吗?"
它能够正确地恢复它,所以不管问题是什么,它一定不会那么严重,但我有一点时间搞清楚问题是什么.我不能做任何简单的事情,比如在调试器下运行Excel,因为它是专有软件.我已经尝试将修正后的版本保存为各种版本的XLS并将这两个文件区分开来,但我找不到任何看起来像原始文件格式一样远的版本.恢复完成后,它会向我提供一个XML文件的链接,该文件指出文档已恢复,而不会对已发现或修复的错误进行任何描述.
有什么方法可以获得一些关于Excel期望看到什么以及它看到了什么的实际详细信息?
有没有办法在Export to Excel函数中使用此功能从UniversalSortableDateTimePattern单独获取日期.Excel不接受日期格式..
我需要显示为yyyy-MM-dd.任何建议都会有所帮助吗?我的代码为
dtASalesDrivers.Columns.Add(new System.Data.DataColumn("Start Date", typeof(String)));
DateTime dt = Convert.ToDateTime(txtATrendStartDate.Text);
drASalesDrivers[2] = string.Format("{0:yyyy-MM-dd}", dt);
dtASalesDrivers.Rows.Add(drASalesDrivers);
Run Code Online (Sandbox Code Playgroud)
编辑:
DateTime dt = Convert.ToDateTime(txtATrendStartDate.Text);
drASalesDrivers[2] = string.Format("{0:u}", dt);
Run Code Online (Sandbox Code Playgroud)
这会显示日期和时间.有没有办法只显示日期???
我正在使用此函数将数据表导出到excel中.
protected void ExportExcel(System.Data.DataTable dt)
{
if (dt == null||dt.Rows.Count==0) return;
Microsoft.Office.Interop.Excel.Application xlApp =
new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
{
return;
}
System.Globalization.CultureInfo CurrentCI =
System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("en-US");
Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks;
Microsoft.Office.Interop.Excel.Workbook workbook =
workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Worksheet worksheet =
(Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];
Microsoft.Office.Interop.Excel.Range range;
long totalCount = dt.Rows.Count;
long rowRead = 0;
float percent = 0;
for (int i = 0; i < dt.Columns.Count; i++)
{
worksheet.Cells[1, i + 1] = dt.Columns[i].ColumnName;
range = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, i + 1];
range.Interior.ColorIndex …Run Code Online (Sandbox Code Playgroud) 我正在研究MVC4项目.我有Devexpress报告工具栏,我有一个自定义按钮导出到excel,因为内置功能有单元合并问题.
无论如何点击该自定义按钮..我想运行导出到Excel代码..但它的工作...我的意思是它返回正确的HTML但不要求提示保存文件/下载文件,可能是因为ajax调用. ..
这是ajax调用的代码
function ReportToolbar_ItemClick(s, e) {
debugger;
if (e.item.name == 'btnCustomeExport') {
// $.post('@Url.Action("ExportToExcel", "Report")');
$.ajax({
url: "@Url.Action("ExportToExcel", "Report")",
type: "POST",
success: function (data, textStatus, jqXHR) {
//data: data from server
alert('success');
},
error: function (jqXHR, textStatus, errorThrown) {
alert('error');
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
和控制器代码:
public ActionResult ExportToExcel()
{
try
{
GridView GridView1 = new GridView();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "EmployeesData.xls"));
Response.ContentType = "application/ms-excel";
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
GridView1.AllowPaging …Run Code Online (Sandbox Code Playgroud) 我使用以下列顺序创建了一个viewson sql server:
当我选择视图时,下面是列的顺序 vwTable
Shift_id | Client_ip | Machine_Center
Run Code Online (Sandbox Code Playgroud)
但是当我要从excel中选择views使用时get external data:
SELECT * FROM vwTable
Run Code Online (Sandbox Code Playgroud)
列的顺序EXCEL不相同,输出为:
Machine_Center | Client_ip | Shift_id
Run Code Online (Sandbox Code Playgroud)
截图:
来自SSMS:
Select * from vwTable
Run Code Online (Sandbox Code Playgroud)

来自excel:获取外部数据
Select * from vwTable
Run Code Online (Sandbox Code Playgroud)

我的问题是列顺序必须相同 views
Servlet和DAO代码如下所示:
@WebServlet("/ExcelExportController")
public class ExcelExportController extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ExcelExportController() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
HttpSession session = request.getSession();
if (session != null) {
FileOutputStream fileOut;
List<LoanOffersDTO> loanOffersDTOs;
ExcelExportDAO excelExportDAO;
HSSFWorkbook hssfWorkbook;
if (session.getAttribute("loanOffers") != null) {
loanOffersDTOs = (List<LoanOffersDTO>) …Run Code Online (Sandbox Code Playgroud) export-to-excel ×10
java ×3
apache-poi ×2
asp.net ×2
c# ×2
excel ×2
coldfusion ×1
coldfusion-8 ×1
datatable ×1
date-format ×1
delphi ×1
devexpress ×1
displaytag ×1
formatting ×1
jquery ×1
jsp ×1
mschart ×1
openxml-sdk ×1
reporting ×1
servlets ×1
sql-server ×1