엑셀로 출력시 줄바꿈 문의드려요~ 정보
엑셀로 출력시 줄바꿈 문의드려요~본문
안녕하세요 게시판에 있는 내용을 엑셀로 출력하는 소스인데요
데이타를 엑셀로 저장을 하면 일렬로 붙어서 출력이 되네요
1.가나다 2.가나다 3.가나다 이런식으로요~
원하는건 이렇게 인데요...
1.가나다
2.가나다
3.가나다
생각하기에 출력할떄 엔터값이안들어 가는거 같아요 흠...
검색을 해보니까 \r\n 을 주면 된다고 하는데 아무리 해도 안되네요
$text= str_replace("\r\n","\n",$text); //window 엔터값
이런 방법도 있다고 하는데 어떻게 해야할지.. 끙...
초보입니다 도와주세요...
아래는 제꺼 소스입니다.
<?
$g4_path = "../../..";
include_once("$g4_path/common.php");
$excel_down = "g4_write_" . $bo_table;
@mysql_query("SET CHARACTER SET utf8"); // 한글깨지면 주석해지
if ($ms =="excel"){
$g4[title] = "excel";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=excel.xls" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="power"){
$g4[title] = "파워포인트 문서 다운로드";
header( "Content-type: application/vnd.ms-powerpoint" );
header( "Content-Disposition: attachment; filename=excel.ppt" );
// header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="word"){
$g4[title] = "워드 문서 다운로드";
header( "Content-type: application/vnd.ms-word" );
header( "Content-Disposition: attachment; filename=excel.doc" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="memo"){
$g4[title] = "메모 문서 다운로드";
header( "Content-type: application/vnd.ms-notepad" );
header( "Content-Disposition: attachment; filename=excel.txt" );
} else {
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=excel.xls" );
}
header( "Content-Description: PHP4 Generated Data" );
/* 해바리님 소스 */
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down where left(wr_datetime,10)='$datetime' "));
$result=mysql_query("select * from $excel_down where left(wr_datetime,10)='$datetime' ");
/* 날자지정 출력 가능(단 서버에서만!)
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down where left(wr_datetime,10)=curdate() "));
$result=mysql_query("select * from $excel_down where left(wr_datetime,10)=curdate() ");
*/
/* 모든데이터 출력 가능
$temp=mysql_fetch_array(mysql_query("select * from table where datetime_col = curdate(); $excel_down "));
$result=@mysql_query("select * from $excel_down order by wr_datetime desc");
*/
$number=$temp[0];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.txt {mso-number-format:'\@'}
</style>
</head>
<body>
<table width=100% cellpadding=0 cellspacing=0 border=1>
<tr align=center height=25 bgcolor=999999>
<td style=font-weight:bold;>번호</td>
<td style=font-weight:bold;>제목</td>
<td style=font-weight:bold;>파트명</td>
<td style=font-weight:bold;>이름</td>
<td style=font-weight:bold;>작성일</td>
<td style=font-weight:bold;>주요이슈 (주간계획/현 주요문제점/비고)</td>
<td style=font-weight:bold;>금일 실적</td>
<td style=font-weight:bold;>명일 계획</td>
</tr>
<?
while($data=mysql_fetch_array($result)) { //에러 뜨는곳
echo "
<tr>
<td>$number</td>
<td>$data[wr_subject]</td>
<td>$data[ca_name]</td>
<td>$data[wr_name]</td>
<td class='txt'>$data[wr_datetime]</td>
<td class='txt'>$data[wr_content]</td>\r\n
<td class='txt'>$data[wr_1]</td>\r\n
<td class='txt'>$data[wr_2]</td>\r\n
</tr>
";
$number--;
}
?>
</table>
</body>
</html>
데이타를 엑셀로 저장을 하면 일렬로 붙어서 출력이 되네요
1.가나다 2.가나다 3.가나다 이런식으로요~
원하는건 이렇게 인데요...
1.가나다
2.가나다
3.가나다
생각하기에 출력할떄 엔터값이안들어 가는거 같아요 흠...
검색을 해보니까 \r\n 을 주면 된다고 하는데 아무리 해도 안되네요
$text= str_replace("\r\n","\n",$text); //window 엔터값
이런 방법도 있다고 하는데 어떻게 해야할지.. 끙...
초보입니다 도와주세요...
아래는 제꺼 소스입니다.
<?
$g4_path = "../../..";
include_once("$g4_path/common.php");
$excel_down = "g4_write_" . $bo_table;
@mysql_query("SET CHARACTER SET utf8"); // 한글깨지면 주석해지
if ($ms =="excel"){
$g4[title] = "excel";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=excel.xls" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="power"){
$g4[title] = "파워포인트 문서 다운로드";
header( "Content-type: application/vnd.ms-powerpoint" );
header( "Content-Disposition: attachment; filename=excel.ppt" );
// header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="word"){
$g4[title] = "워드 문서 다운로드";
header( "Content-type: application/vnd.ms-word" );
header( "Content-Disposition: attachment; filename=excel.doc" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="memo"){
$g4[title] = "메모 문서 다운로드";
header( "Content-type: application/vnd.ms-notepad" );
header( "Content-Disposition: attachment; filename=excel.txt" );
} else {
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=excel.xls" );
}
header( "Content-Description: PHP4 Generated Data" );
/* 해바리님 소스 */
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down where left(wr_datetime,10)='$datetime' "));
$result=mysql_query("select * from $excel_down where left(wr_datetime,10)='$datetime' ");
/* 날자지정 출력 가능(단 서버에서만!)
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down where left(wr_datetime,10)=curdate() "));
$result=mysql_query("select * from $excel_down where left(wr_datetime,10)=curdate() ");
*/
/* 모든데이터 출력 가능
$temp=mysql_fetch_array(mysql_query("select * from table where datetime_col = curdate(); $excel_down "));
$result=@mysql_query("select * from $excel_down order by wr_datetime desc");
*/
$number=$temp[0];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.txt {mso-number-format:'\@'}
</style>
</head>
<body>
<table width=100% cellpadding=0 cellspacing=0 border=1>
<tr align=center height=25 bgcolor=999999>
<td style=font-weight:bold;>번호</td>
<td style=font-weight:bold;>제목</td>
<td style=font-weight:bold;>파트명</td>
<td style=font-weight:bold;>이름</td>
<td style=font-weight:bold;>작성일</td>
<td style=font-weight:bold;>주요이슈 (주간계획/현 주요문제점/비고)</td>
<td style=font-weight:bold;>금일 실적</td>
<td style=font-weight:bold;>명일 계획</td>
</tr>
<?
while($data=mysql_fetch_array($result)) { //에러 뜨는곳
echo "
<tr>
<td>$number</td>
<td>$data[wr_subject]</td>
<td>$data[ca_name]</td>
<td>$data[wr_name]</td>
<td class='txt'>$data[wr_datetime]</td>
<td class='txt'>$data[wr_content]</td>\r\n
<td class='txt'>$data[wr_1]</td>\r\n
<td class='txt'>$data[wr_2]</td>\r\n
</tr>
";
$number--;
}
?>
</table>
</body>
</html>
댓글 전체
번호 제목 파트명 이름 작성일 주요이슈 (주간계획/현 주요문제점/비고 금일 실적 명일 계획
01 aaa bbbb 길동 10.01 ccccccccccccccccccccccccccccccc 500,000 200,000
02 aaa bbbb 길동 10.01 ccccccccccccccccccccccccccccccc 500,000 200,000
03 aaa bbbb 길동 10.01 ccccccccccccccccccccccccccccccc 500,000 200,000
이런씩으로 출력 되는데...
<td class='txt'>$data[wr_content]</td>\r\n
<td class='txt'>$data[wr_1]</td>\r\n
<td class='txt'>$data[wr_2]</td>\r\n
세로로 출력되게 말입니까? tr 태그 사용하면 됩니다만.
<tr><td class='txt'>$data[wr_content]</td></tr>
<tr><td class='txt'>$data[wr_1]</td></tr>
<tr><td class='txt'>$data[wr_2]</td></tr>
이렇게 출력이면 제목줄과 아래 데이터가 틀리는데...
번호 제목 파트명
이름 작성일 주요이슈 (주간계획/현 주요문제점/비고
금일실적 명일계획
이런순으로 데이타 출력인가요?
위에 필드명으로 정확히 설명이 있어야...
01 aaa bbbb 길동 10.01 ccccccccccccccccccccccccccccccc 500,000 200,000
02 aaa bbbb 길동 10.01 ccccccccccccccccccccccccccccccc 500,000 200,000
03 aaa bbbb 길동 10.01 ccccccccccccccccccccccccccccccc 500,000 200,000
이런씩으로 출력 되는데...
<td class='txt'>$data[wr_content]</td>\r\n
<td class='txt'>$data[wr_1]</td>\r\n
<td class='txt'>$data[wr_2]</td>\r\n
세로로 출력되게 말입니까? tr 태그 사용하면 됩니다만.
<tr><td class='txt'>$data[wr_content]</td></tr>
<tr><td class='txt'>$data[wr_1]</td></tr>
<tr><td class='txt'>$data[wr_2]</td></tr>
이렇게 출력이면 제목줄과 아래 데이터가 틀리는데...
번호 제목 파트명
이름 작성일 주요이슈 (주간계획/현 주요문제점/비고
금일실적 명일계획
이런순으로 데이타 출력인가요?
위에 필드명으로 정확히 설명이 있어야...
아 제가 설명이 좀 애매했나보네요
주요이슈 쪽 데이타 내용을 예로들면
1.어떤내용
2.그런내용
이런식으로 게시판에 작성을 하였는데 엑셀로 출력하면
1.어떤내요 2.그런내용
이런식으로 일렬로 붙어서 나오네요
\r\n으로 설정을 해도 엑셀로 출력해도 붙어서 나오니까 머리아프네요 ^^;;
주요이슈 쪽 데이타 내용을 예로들면
1.어떤내용
2.그런내용
이런식으로 게시판에 작성을 하였는데 엑셀로 출력하면
1.어떤내요 2.그런내용
이런식으로 일렬로 붙어서 나오네요
\r\n으로 설정을 해도 엑셀로 출력해도 붙어서 나오니까 머리아프네요 ^^;;
해바리님 소스가지고 하다보니 재미있는것도 수정되네요
주요이슈사항쪽 데이터를 받아올때 어떤글은 ########################## 이런식으로
내용이 표시되는 사항이 있었는데 해바리님 소스에서 조금만 수정하니까
<tr><td class='text'>$data[wr_content]</td></tr>
<tr><td class='text'>$data[wr_1]</td></tr>
<tr><td class='text'>$data[wr_2]</td></tr>
이런식으로 하니 ################# 표시되는 내용이 제대로 나오네요 ^^
그래도 엔터값을 인식해서 엑셀에서 줄바꿈은 변경이 안되네요 계속 수정중 끙..
주요이슈사항쪽 데이터를 받아올때 어떤글은 ########################## 이런식으로
내용이 표시되는 사항이 있었는데 해바리님 소스에서 조금만 수정하니까
<tr><td class='text'>$data[wr_content]</td></tr>
<tr><td class='text'>$data[wr_1]</td></tr>
<tr><td class='text'>$data[wr_2]</td></tr>
이런식으로 하니 ################# 표시되는 내용이 제대로 나오네요 ^^
그래도 엔터값을 인식해서 엑셀에서 줄바꿈은 변경이 안되네요 계속 수정중 끙..
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>제목</title>
</head>
<body>
<table border=1>
<tr>
<td width=50>번호</td>
<td>제목</td>
<td>파트명</td>
<td>이름</td>
<td>작성일</td>
<td width=500>주요이슈 (주간계획/현 주요문제점/비고)</td>
<td>금일실적</td>
<td>명일계획</td>
</tr>
<? while ($row = mysql_fetch_array($result)) {
$no=++$no;
?>
<tr>
<td align=center><?=$no?></td>
<td><?=$row['wr_subject']?></td>
<td><?=$row['ca_name']?></td>
<td><?=$row['wr_name']?></td>
<td><?=$row['wr_datetime']?></td>
<td><?=trim($row['wr_content'])?></td>
<td><?=$row['wr_1']?></td>
<td><?=$row['wr_2']?></td>
</tr>
<? } ?>
</table>
<script language = "javascript">
history.back();
</script>
</body>
</html>
아래처럼 넓이를 주어보세요. 그렇면 넓이 만큼 출력되고 다음줄로 시작합니다.
<td width=500>주요이슈 (주간계획/현 주요문제점/비고)</td>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>제목</title>
</head>
<body>
<table border=1>
<tr>
<td width=50>번호</td>
<td>제목</td>
<td>파트명</td>
<td>이름</td>
<td>작성일</td>
<td width=500>주요이슈 (주간계획/현 주요문제점/비고)</td>
<td>금일실적</td>
<td>명일계획</td>
</tr>
<? while ($row = mysql_fetch_array($result)) {
$no=++$no;
?>
<tr>
<td align=center><?=$no?></td>
<td><?=$row['wr_subject']?></td>
<td><?=$row['ca_name']?></td>
<td><?=$row['wr_name']?></td>
<td><?=$row['wr_datetime']?></td>
<td><?=trim($row['wr_content'])?></td>
<td><?=$row['wr_1']?></td>
<td><?=$row['wr_2']?></td>
</tr>
<? } ?>
</table>
<script language = "javascript">
history.back();
</script>
</body>
</html>
아래처럼 넓이를 주어보세요. 그렇면 넓이 만큼 출력되고 다음줄로 시작합니다.
<td width=500>주요이슈 (주간계획/현 주요문제점/비고)</td>
흠.. 그래도 줄바꿈이 안되네요
이유가 뭘까요 글을적을때 엔터값이 들어갈텐데요...
흠..
이유가 뭘까요 글을적을때 엔터값이 들어갈텐데요...
흠..