建置Excel 儲存格中,可看可複製的換行效果

  通常在網路上,可以容易找到有關 Excel 儲存格中,要產生換行效果的作法;也就是利用 Alt + Enter 換行。

例如:ABC (換行) DEF (換行) GHI (換行) JKL
       可以在編輯區中,看到 image
       儲存格則顯示成 image

同理,打出下列式子,也可以看到換行的效果。
"if (list[i].Equals(listm[" & B1 & "]))" &
" {" &
" table[i] = """ & C1 & """; " &
" SQLselect += "",a." & C1 & """; " &
" }"

但是,仔細一看 式子 中,不是要引用到其他的儲存格內容嗎?這不就是要用公式才行嗎?

是的,所以就式子的前面加上等號吧 !!

這時編輯區會是image
而儲存格的內容,就變成為
image

什麼,即然變成一行,這可不是我所要了 !!!

看上面的內容,就知道它是程式碼的一部份,也就是 if 指令的區塊碼。這程式碼若能像編輯時能換行,看起來不就會好看多了。這該如何改善呢?

方法:超極簡單 ==> 加上 "CHAR(10) &"

這樣,
編輯區看到image
儲存格的內容,就變成 image

注點:該儲存格中的要引用到的內容,也能正常被引用到。真好

若是要複製程式開發環境,可先貼到 WORD 上面,再複製、貼上。

如何引入外圍資料庫資料,來新增記錄?

image

新增記錄的 SQL 指令語法:
INSERT target_table
SELECT 'SELECT', authors.au_id, authors.au_lname, SUM(titles.price * sales.qty)
FROM authors
INNER JOIN titleauthor ON authors.au_id = titleauthor.au_id
INNER JOIN titles ON titleauthor.title_id = titles.title_id
INNER JOIN sales ON titles.title_id = sales.title_id
WHERE authors.au_id LIKE '8%'
GROUP BY authors.au_id, authors.au_lname

當資料來源與增建記錄的資料表,是不同資料庫時,
就需要用 OpenDataSource() 來開啟外圍資料庫的資料表。

用法如上所述。

 

Examples

This example accesses data from a table on another instance of SQL Server.

SELECT   *
FROM OPENDATASOURCE(
'SQLOLEDB',
'Data Source=ServerName;User ID=MyUID;Password=MyPass'
).Northwind.dbo.Categories


This is an example of a query against an Excel spreadsheet through the OLE DB provider for Jet.



SELECT * 
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions

Access 功能區(Ribbon) 該如何隱藏?

Access 2007 之前的版本,提供自訂工具列、功能表列的功能。但這些功能在 2007之後,因為使用新的使用者介面(功能區索引標籤)、功能區群組與指令,而被取代。

在 Access 2007 之後的功能區,又該如何被隱藏?

By default, Microsoft Office Access 2007 does not provide a method for hiding the Ribbon. This topic describes how to load a customized ribbon that hides all of the built-in tabs.

To load the customized ribbon when Access starts, you should store its settings in a table named USysRibbons.

The USysRibbons table must be created using specific column names in order for the Ribbon customizations to be implemented. The following table describes the settings to use when creating the USysRibbons table.

Column Name Data Type Description
RibbonName Text Contains the name of the custom ribbon to be associated with this customization.
RibbonXML Memo Contains the Ribbon Extensibility XML (RibbonX) that defines the Ribbon customization.

 

The following table describes the Ribbon customization settings to store in the USysRibbons table.

Column Name Value
RibbonName HideTheRibbon
RibbonXML <customUI xmlns=http://schemas.microsoft.com/office/2006/01/customui>
  <ribbon startFromScratch="true"/>
</customUI>


Applying the Customized Ribbon When Access Starts

To implement a custom UI so that it is available when the application starts, do the following:

  1. Follow the process described previously to make the customized ribbon available to the application.
  2. Close and then restart the application.
  3. Click the Microsoft Office Button Button image and then click Access Options.
  4. Click the Current Database option and then, in the Ribbon and Toolbar Options section, click the Ribbon Name list and select HideTheRibbon.
  5. Close and restart the application.

報表簽名欄內容的設定

有些水晶報表設有特定簽名欄位,這些資料需要在 A3/Q6 中設定。
否則,列印出來的報表"簽名欄"會是 空白。

image

編譯後,運行才有的錯誤

在開發設計階段,程式均能正常運作,產生 *.XML 檔案。

但是在編譯後,運行卻有下列的錯誤訊息:

image

 

mFile.WriteLine("<Cell><Data ss:Type=\"Number\" >" + Chks.ToDecimal(RptSource.Rows[i]["cnt"]) + "</Data></Cell>");

修正為

mFile.WriteLine("<Cell><Data ss:Type=\"Number\" >" + Chks.ToDecimal(RptSource.Rows[i]["cnt"]).ToString("G0") + "</Data></Cell>");

也可以改用

mFile.WriteLine("<Cell><Data ss:Type=\"Number\" >" + (Chks.ToDecimal(RptSource.Rows[i]["cnt"]) == 0 ? Math.Round(0m, 0) : Math.Round(Chks.ToDecimal(RptSource.Rows[i]["cnt"]), 0)) + "</Data></Cell>");

帶有資料類型 Number 的儲存格必須有一個值

image

經查證程式碼,發現原程式

mFile.WriteLine("<Cell ss:Index=\"2\" ss:Formula=\"=SUM(INDIRECT(ADDRESS(1,COLUMN()) &amp; &quot;:&quot; &amp; ADDRESS(ROW()-1,COLUMN())))\"><Data ss:Type=\"Number\"></Data></Cell>");

 

修改如下,即可解決問題

mFile.WriteLine("<Cell ss:Index=\"2\" ss:Formula=\"=SUM(INDIRECT(ADDRESS(1,COLUMN()) &amp; &quot;:&quot; &amp; ADDRESS(ROW()-1,COLUMN())))\"><Data ss:Type=\"Number\">0</Data></Cell>");

即使是代公式方式來計算數值,也需要先給該欄位設定一默認值。